diff --git a/src/components/timeline/timeline.js b/src/components/timeline/timeline.js index 7600e1765..1f4486647 100644 --- a/src/components/timeline/timeline.js +++ b/src/components/timeline/timeline.js @@ -38,7 +38,6 @@ const Timeline = { showScrollTop: false, paused: false, unfocused: false, - virtualScrollIndex: 0, blockingClicks: false, } }, @@ -102,20 +101,7 @@ const Timeline = { } }, statusesToDisplay() { - if (!this.virtualScrollingEnabled) { - return new Set(this.filteredVisibleStatuses.map(({ id }) => id)) - } - - const amount = this.timeline.visibleStatusIds.size - const statusesPerSide = Math.ceil(Math.max(3, window.innerHeight / 80)) - const min = Math.max(0, this.virtualScrollIndex - statusesPerSide) - const max = Math.min(amount, this.virtualScrollIndex + statusesPerSide) - return new Set( - this.filteredVisibleStatuses.slice(min, max).map(({ id }) => id), - ) - }, - virtualScrollingEnabled() { - return useMergedConfigStore().mergedConfig.virtualScrolling + return new Set(this.filteredVisibleStatuses.map(({ id }) => id)) }, ...mapState(useInterfaceStore, { mobileLayout: (store) => store.layoutType === 'mobile', @@ -135,7 +121,6 @@ const Timeline = { } window.addEventListener('keydown', this.handleShortKey) window.addEventListener('scroll', this.handleScroll) - setTimeout(this.determineVisibleStatuses, 250) }, unmounted() { this.timelineChange(null, this.timelineRef) @@ -193,54 +178,6 @@ const Timeline = { 1000, this, ), - determineVisibleStatuses() { - if (!this.$refs.timeline) return - if (!this.virtualScrollingEnabled) return - - const statuses = this.$refs.timeline.children - if (statuses.length === 0) return - const cappedScrollIndex = Math.max( - 0, - Math.min(this.virtualScrollIndex, statuses.length - 1), - ) - - const height = Math.max(document.body.offsetHeight, window.pageYOffset) - - const centerOfScreen = window.pageYOffset + window.innerHeight * 0.5 - - // Start from approximating the index of some visible status by using the - // the center of the screen on the timeline. - let approxIndex = Math.min( - Math.floor(statuses.length * (centerOfScreen / height)), - statuses.length - 1, - ) - let err = statuses[approxIndex].getBoundingClientRect().y - - // if we have a previous scroll index that can be used, test if it's - // closer than the previous approximation, use it if so - - const virtualScrollIndexY = - statuses[cappedScrollIndex].getBoundingClientRect().y - if (Math.abs(err) > virtualScrollIndexY) { - approxIndex = cappedScrollIndex - err = virtualScrollIndexY - } - - // if the status is too far from viewport, check the next/previous ones if - // they happen to be better - while (err < -20 && approxIndex < statuses.length - 1) { - err += statuses[approxIndex].offsetHeight - approxIndex++ - } - while (err > window.innerHeight + 100 && approxIndex > 0) { - approxIndex-- - err -= statuses[approxIndex].offsetHeight - } - - // this status is now the center point for virtual scrolling and visible - // statuses will be nearby statuses before and after it - this.virtualScrollIndex = approxIndex - }, scrollLoad() { // TODO simplify this logic const bodyBRect = document.body.getBoundingClientRect() @@ -253,7 +190,6 @@ const Timeline = { } }, handleScroll: throttle(function (e) { - this.determineVisibleStatuses() this.scrollLoad(e) }, 200), handleVisibilityChange() { @@ -264,9 +200,6 @@ const Timeline = { timelineRef(newTimeline, oldTimeline) { this.timelineChange(newTimeline, oldTimeline) }, - filteredVisibleStatuses() { - this.determineVisibleStatuses() - }, newStatusCount(count) { if (!useMergedConfigStore().mergedConfig.streaming) { return diff --git a/src/components/timeline/timeline.scss b/src/components/timeline/timeline.scss index 984129bf4..364882232 100644 --- a/src/components/timeline/timeline.scss +++ b/src/components/timeline/timeline.scss @@ -4,6 +4,10 @@ backdrop-filter: none; } + .vue-recycle-scroller.timeline { + overflow: visible; + } + .timeline-placeholder { background: var(--background); display: flex; diff --git a/src/components/timeline/timeline.vue b/src/components/timeline/timeline.vue index 5b34551bc..7ee4bcfc5 100644 --- a/src/components/timeline/timeline.vue +++ b/src/components/timeline/timeline.vue @@ -77,23 +77,35 @@ />
-
- -
+ +