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 = { ...@@ -158,6 +158,7 @@ const Timeline = {
if (!this.virtualScrollingEnabled) return if (!this.virtualScrollingEnabled) return
const statuses = this.$refs.timeline.children const statuses = this.$refs.timeline.children
const cappedScrollIndex = Math.max(0, Math.min(this.virtualScrollIndex, statuses.length - 1))
if (statuses.length === 0) return if (statuses.length === 0) return
...@@ -173,12 +174,9 @@ const Timeline = { ...@@ -173,12 +174,9 @@ const Timeline = {
// if we have a previous scroll index that can be used, test if it's // if we have a previous scroll index that can be used, test if it's
// closer than the previous approximation, use it if so // closer than the previous approximation, use it if so
const virtualScrollIndexY = statuses[this.virtualScrollIndex].getBoundingClientRect().y const virtualScrollIndexY = statuses[cappedScrollIndex].getBoundingClientRect().y
if ( if (Math.abs(err) > virtualScrollIndexY) {
this.virtualScrollIndex < statuses.length && approxIndex = cappedScrollIndex
Math.abs(err) > virtualScrollIndexY
) {
approxIndex = this.virtualScrollIndex
err = virtualScrollIndexY err = virtualScrollIndexY
} }
...@@ -210,7 +208,7 @@ const Timeline = { ...@@ -210,7 +208,7 @@ const Timeline = {
handleScroll: throttle(function (e) { handleScroll: throttle(function (e) {
this.determineVisibleStatuses() this.determineVisibleStatuses()
this.scrollLoad(e) this.scrollLoad(e)
}, 100), }, 150),
handleVisibilityChange () { handleVisibilityChange () {
this.unfocused = document.hidden 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