From 58fdd50838f00f1f9594079680e1e60d3572ef30 Mon Sep 17 00:00:00 2001 From: Alexander Tumin Date: Sat, 1 Aug 2026 23:36:31 +0300 Subject: [PATCH] fix status index approxmiation in timeline rendering for dynamically changing viewport geometries --- changelog.d/timeline_rendering_status_index_approx.fix | 1 + src/components/timeline/timeline.js | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 changelog.d/timeline_rendering_status_index_approx.fix 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