From a87c4cf5ddb373ee9058f9fdac6ab2cbb967bcf5 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Wed, 9 Sep 2026 01:20:33 +0300 Subject: [PATCH] remove old virtual scrolling --- src/components/timeline/timeline.js | 66 +--------------------------- src/components/timeline/timeline.vue | 1 - src/modules/default_config_state.js | 4 -- 3 files changed, 1 insertion(+), 70 deletions(-) diff --git a/src/components/timeline/timeline.js b/src/components/timeline/timeline.js index 637c7fb82..79b8f493b 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, } }, @@ -107,20 +106,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', @@ -140,7 +126,6 @@ const Timeline = { } window.addEventListener('keydown', this.handleShortKey) window.addEventListener('scroll', this.handleScroll) - setTimeout(this.determineVisibleStatuses, 250) }, unmounted() { this.timelineChange(null, this.timelineRef) @@ -198,54 +183,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() @@ -258,7 +195,6 @@ const Timeline = { } }, handleScroll: throttle(function (e) { - this.determineVisibleStatuses() this.scrollLoad(e) }, 200), handleVisibilityChange() { diff --git a/src/components/timeline/timeline.vue b/src/components/timeline/timeline.vue index 905b94382..8388f59e7 100644 --- a/src/components/timeline/timeline.vue +++ b/src/components/timeline/timeline.vue @@ -86,7 +86,6 @@ v-for="status in filteredVisibleStatuses" :key="status.id" :status-id="status.id" - :virtual-hidden="virtualScrollingEnabled && !statusesToDisplay.has(status.id)" role="listitem" /> diff --git a/src/modules/default_config_state.js b/src/modules/default_config_state.js index 9643b1856..66c756659 100644 --- a/src/modules/default_config_state.js +++ b/src/modules/default_config_state.js @@ -457,10 +457,6 @@ export const INSTANCE_DEFAULT_CONFIG_DEFINITIONS = { description: 'Hide user stats (followers etc)', default: false, }, - virtualScrolling: { - description: 'Timeline virtual scrolling', - default: true, - }, sensitiveByDefault: { description: 'Assume attachments are NSFW by default', default: false,