From 8a711408de26c53cf6b18045ea19c677e8edbd95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Thu, 20 Apr 2023 15:48:34 +0200 Subject: [PATCH] Compare absolute offsets as well in `notify_on_scroll` --- native/src/widget/scrollable.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/native/src/widget/scrollable.rs b/native/src/widget/scrollable.rs index c66a166be3..c9ad5947d2 100644 --- a/native/src/widget/scrollable.rs +++ b/native/src/widget/scrollable.rs @@ -913,14 +913,21 @@ fn notify_on_scroll( // Don't publish redundant viewports to shell if let Some(last_notified) = state.last_notified { - let prev = last_notified.relative_offset(); - let curr = viewport.relative_offset(); + let last_relative_offset = last_notified.relative_offset(); + let current_relative_offset = viewport.relative_offset(); + + let last_absolute_offset = last_notified.absolute_offset(); + let current_absolute_offset = viewport.absolute_offset(); let unchanged = |a: f32, b: f32| { (a - b).abs() <= f32::EPSILON || (a.is_nan() && b.is_nan()) }; - if unchanged(prev.x, curr.x) && unchanged(prev.y, curr.y) { + if unchanged(last_relative_offset.x, current_relative_offset.x) + && unchanged(last_relative_offset.y, current_relative_offset.y) + && unchanged(last_absolute_offset.x, current_absolute_offset.x) + && unchanged(last_absolute_offset.y, current_absolute_offset.y) + { return; } }