Commit 16408410 authored by Shpuld Shpludson's avatar Shpuld Shpludson

cap virtual scroll index before use

parent 686a8e1c
Pipeline #23782 passed with stages
in 7 minutes and 10 seconds
......@@ -158,6 +158,7 @@ const Timeline = {
if (!this.virtualScrollingEnabled) return
const statuses = this.$refs.timeline.children
const cappedScrollIndex = Math.max(0, Math.min(this.virtualScrollIndex, statuses.length - 1))
if (statuses.length === 0) return
......@@ -173,12 +174,9 @@ const Timeline = {
// 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[this.virtualScrollIndex].getBoundingClientRect().y
if (
this.virtualScrollIndex < statuses.length &&
Math.abs(err) > virtualScrollIndexY
) {
approxIndex = this.virtualScrollIndex
const virtualScrollIndexY = statuses[cappedScrollIndex].getBoundingClientRect().y
if (Math.abs(err) > virtualScrollIndexY) {
approxIndex = cappedScrollIndex
err = virtualScrollIndexY
}
......@@ -210,7 +208,7 @@ const Timeline = {
handleScroll: throttle(function (e) {
this.determineVisibleStatuses()
this.scrollLoad(e)
}, 100),
}, 150),
handleVisibilityChange () {
this.unfocused = document.hidden
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment