From b2848a54b05470b3e258c935dd33b8c11a31b3c3 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Tue, 9 Jan 2018 12:07:45 -0800 Subject: [PATCH] Adding support to float values for Android snapToInterval Reviewed By: fkgozali Differential Revision: D6684529 fbshipit-source-id: 51efa0a2d38acf4134bb824c462973e5c6bdf17a --- RNTester/js/ScrollViewSimpleExample.js | 2 +- .../react/views/scroll/ReactHorizontalScrollViewManager.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/RNTester/js/ScrollViewSimpleExample.js b/RNTester/js/ScrollViewSimpleExample.js index 56dd7745e..c3ac0786b 100644 --- a/RNTester/js/ScrollViewSimpleExample.js +++ b/RNTester/js/ScrollViewSimpleExample.js @@ -50,7 +50,7 @@ class ScrollViewSimpleExample extends React.Component<{}> { {this.makeItems(NUM_ITEMS, [ diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollViewManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollViewManager.java index e920e22b0..9b59dc6c5 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollViewManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollViewManager.java @@ -73,9 +73,10 @@ public class ReactHorizontalScrollViewManager } @ReactProp(name = "snapToInterval") - public void setSnapToInterval(ReactHorizontalScrollView view, int snapToInterval) { + public void setSnapToInterval(ReactHorizontalScrollView view, float snapToInterval) { + // snapToInterval needs to be exposed as a float because of the Javascript interface. DisplayMetrics screenDisplayMetrics = DisplayMetricsHolder.getScreenDisplayMetrics(); - view.setSnapInterval((int)(snapToInterval * screenDisplayMetrics.density)); + view.setSnapInterval((int) (snapToInterval * screenDisplayMetrics.density)); } @ReactProp(name = ReactClippingViewGroupHelper.PROP_REMOVE_CLIPPED_SUBVIEWS)