From 681b35daab2d0443278fe18c364b0e72c8c85673 Mon Sep 17 00:00:00 2001 From: Tomek Zawadzki Date: Thu, 9 Feb 2023 15:51:25 -0800 Subject: [PATCH] Fix ScrollView momentum not stopping when calling scrollTo programmatically (#36104) Summary: Fixes https://github.com/facebook/react-native/issues/32235. See https://github.com/facebook/react-native/issues/32235#issuecomment-1420826665 for details. Before: https://user-images.githubusercontent.com/20516055/217268275-7ec9a228-bbd6-4294-aa1f-a43c4268984c.mov After: https://user-images.githubusercontent.com/20516055/217786242-f44b008f-6c6d-4f11-a7bd-b7a01150f3fb.mov ## Changelog [ANDROID] [FIXED] - Fixed ScrollView momentum not stopping when calling scrollTo programmatically Pull Request resolved: https://github.com/facebook/react-native/pull/36104 Test Plan: Reproducer: https://github.com/tomekzaw/Issue32235/blob/master/App.tsx Reviewed By: christophpurrer Differential Revision: D43153500 Pulled By: cortinico fbshipit-source-id: ac9c5ed754ed8ba72fe45d506c76f52d795dc83e --- .../java/com/facebook/react/views/scroll/ReactScrollView.java | 1 + 1 file changed, 1 insertion(+) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java b/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java index 2442f7b2013d55..6bda8b8826b474 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java @@ -1076,6 +1076,7 @@ public void reactSmoothScrollTo(int x, int y) { */ @Override public void scrollTo(int x, int y) { + mScroller.abortAnimation(); super.scrollTo(x, y); ReactScrollViewHelper.updateFabricScrollState(this); setPendingContentOffsets(x, y);