diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-06-06 01:54:24 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-06-06 01:54:24 +0900 |
| commit | 062fbd7d271c0ee787a355c9d1a4d7ffc038759a (patch) | |
| tree | 8750024975fbf3b4f0ae44422a4153ece0c68b3d /src/client | |
| parent | 2.26.0 (diff) | |
| download | sharkey-062fbd7d271c0ee787a355c9d1a4d7ffc038759a.tar.gz sharkey-062fbd7d271c0ee787a355c9d1a4d7ffc038759a.tar.bz2 sharkey-062fbd7d271c0ee787a355c9d1a4d7ffc038759a.zip | |
wip
Diffstat (limited to 'src/client')
| -rw-r--r-- | src/client/app/desktop/views/pages/deck/deck.column.vue | 49 | ||||
| -rw-r--r-- | src/client/app/desktop/views/pages/deck/deck.notes.vue | 35 |
2 files changed, 46 insertions, 38 deletions
diff --git a/src/client/app/desktop/views/pages/deck/deck.column.vue b/src/client/app/desktop/views/pages/deck/deck.column.vue index 8d0b3c0fdb..eb1c47c46c 100644 --- a/src/client/app/desktop/views/pages/deck/deck.column.vue +++ b/src/client/app/desktop/views/pages/deck/deck.column.vue @@ -1,6 +1,6 @@ <template> <div class="dnpfarvgbnfmyzbdquhhzyxcmstpdqzs"> - <header> + <header :class="{ indicate }"> <slot name="header"></slot> </header> <div ref="body"> @@ -11,30 +11,44 @@ <script lang="ts"> import Vue from 'vue'; -import XTl from './deck.tl.vue'; export default Vue.extend({ - components: { - XTl + data() { + return { + indicate: false + }; }, + provide() { return { - getColumn() { - return this; - }, - getScrollContainer() { - return this.$refs.body; - } + column: this, + isScrollTop: this.isScrollTop, + indicate: v => this.indicate = v }; }, + mounted() { - this.$nextTick(() => { - this.$emit('mounted'); + this.$refs.body.addEventListener('scroll', this.onScroll); + }, + beforeDestroy() { + this.$refs.body.removeEventListener('scroll', this.onScroll); + }, + + methods: { + isScrollTop() { + return this.$refs.body.scrollTop == 0; + }, + + onScroll() { + if (this.isScrollTop()) { + this.$emit('top'); + } - setInterval(() => { - this.$emit('mounted'); - }, 100); - }); + if (this.$store.state.settings.fetchOnScroll !== false) { + const current = this.$refs.body.scrollTop + this.$refs.body.clientHeight; + if (current > this.$refs.body.scrollHeight - 1) this.$emit('bottom'); + } + } } }); </script> @@ -61,6 +75,9 @@ root(isDark) background isDark ? #313543 : #fff box-shadow 0 1px rgba(#000, 0.15) + &.indicate + box-shadow 0 3px 0 0 $theme-color + > div height calc(100% - 42px) overflow auto diff --git a/src/client/app/desktop/views/pages/deck/deck.notes.vue b/src/client/app/desktop/views/pages/deck/deck.notes.vue index 48be4e585c..e05b31c32e 100644 --- a/src/client/app/desktop/views/pages/deck/deck.notes.vue +++ b/src/client/app/desktop/views/pages/deck/deck.notes.vue @@ -1,7 +1,5 @@ <template> <div class="eamppglmnmimdhrlzhplwpvyeaqmmhxu"> - <div class="newer-indicator" v-show="queue.length > 0"></div> - <slot name="empty" v-if="notes.length == 0 && !fetching && requestInitPromise == null"></slot> <div v-if="!fetching && requestInitPromise != null"> @@ -42,6 +40,8 @@ export default Vue.extend({ XNote }, + inject: ['column', 'isScrollTop', 'indicate'], + props: { more: { type: Function, @@ -73,25 +73,17 @@ export default Vue.extend({ } }, - inject: ['getColumn', 'getScrollContainer'], - created() { - this.getColumn().$once('mounted', () => { - this.rootEl = this.getScrollContainer(); - this.rootEl.addEventListener('scroll', this.onScroll); - }) + this.column.$on('top', this.onTop); + this.column.$on('bottom', this.onBottom); }, beforeDestroy() { - this.rootEl.removeEventListener('scroll', this.onScroll); + this.column.$off('top', this.onTop); + this.column.$off('bottom', this.onBottom); }, methods: { - isScrollTop() { - if (this.rootEl == null) return true; - return this.rootEl.scrollTop <= 8; - }, - focus() { (this.$el as any).children[0].focus(); }, @@ -149,6 +141,7 @@ export default Vue.extend({ } } else { this.queue.push(note); + this.indicate(true); } }, @@ -163,6 +156,7 @@ export default Vue.extend({ releaseQueue() { this.queue.forEach(n => this.prepend(n, true)); this.queue = []; + this.indicate(false); }, async loadMore() { @@ -174,15 +168,12 @@ export default Vue.extend({ this.moreFetching = false; }, - onScroll() { - if (this.isScrollTop()) { - this.releaseQueue(); - } + onTop() { + this.releaseQueue(); + }, - if (this.rootEl && this.$store.state.settings.fetchOnScroll !== false) { - const current = this.rootEl.scrollTop + this.rootEl.clientHeight; - if (current > this.rootEl.scrollHeight - 8) this.loadMore(); - } + onBottom() { + this.loadMore(); } } }); |