From 21fce196bab1359311ec7f82cc9f7ec3a2a59fe1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Istv=C3=A1n=20So=C3=B3s?= Date: Fri, 5 Jan 2024 16:26:31 +0100 Subject: [PATCH] Slightly simpler scrollTo logic for foldable components. (#7345) --- pkg/web_app/lib/src/foldable.dart | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/pkg/web_app/lib/src/foldable.dart b/pkg/web_app/lib/src/foldable.dart index ac4b15520a..224eb8037a 100644 --- a/pkg/web_app/lib/src/foldable.dart +++ b/pkg/web_app/lib/src/foldable.dart @@ -29,7 +29,6 @@ void _setEventForFoldable() { return; } - num scrollDiff = 0; if (scrollContainer != null) { // Wait one animation frame before measurements. await window.animationFrame; @@ -50,18 +49,12 @@ void _setEventForFoldable() { final screenLimit = scrollContainerHeight - buttonHeight; /// Scroll the smaller amount of the two. - scrollDiff = max(0, min(screenLimit, outsideViewDiff)); + final scrollDiff = max(0, min(screenLimit, outsideViewDiff)); - /// Do not scroll if the difference is small, otherwise scroll in small - /// steps synchronized to the animation frames. + /// Do not scroll if the difference is small. if (scrollDiff > 8) { final originalScrollTop = scrollContainer.scrollTop; - final maxSteps = 20; - for (var i = 1; i <= maxSteps; i++) { - if (i > 1) await window.animationFrame; - final nextPos = originalScrollTop + (scrollDiff * i / maxSteps); - scrollContainer.scrollTo(0, nextPos); - } + scrollContainer.scrollTo(0, originalScrollTop + scrollDiff); } } }