diff --git a/changelog.d/timeline_rendering_status_index_approx.fix b/changelog.d/timeline_rendering_status_index_approx.fix new file mode 100644 index 000000000..717464c58 --- /dev/null +++ b/changelog.d/timeline_rendering_status_index_approx.fix @@ -0,0 +1 @@ +Fixed status index approxmiation in timeline rendering for dynamically changing viewport geometries diff --git a/src/components/timeline/timeline.js b/src/components/timeline/timeline.js index 17065a9ef..c3f4d381d 100644 --- a/src/components/timeline/timeline.js +++ b/src/components/timeline/timeline.js @@ -263,7 +263,10 @@ const Timeline = { // Start from approximating the index of some visible status by using the // the center of the screen on the timeline. - let approxIndex = Math.floor(statuses.length * (centerOfScreen / height)) + 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