Adding support to float values for Android snapToInterval
Reviewed By: fkgozali Differential Revision: D6684529 fbshipit-source-id: 51efa0a2d38acf4134bb824c462973e5c6bdf17a
This commit is contained in:
parent
a8d4666651
commit
b2848a54b0
|
@ -50,7 +50,7 @@ class ScrollViewSimpleExample extends React.Component<{}> {
|
||||||
<ScrollView
|
<ScrollView
|
||||||
key={'scrollViewSnap'}
|
key={'scrollViewSnap'}
|
||||||
horizontal
|
horizontal
|
||||||
snapToInterval={210}
|
snapToInterval={210.0}
|
||||||
pagingEnabled
|
pagingEnabled
|
||||||
>
|
>
|
||||||
{this.makeItems(NUM_ITEMS, [
|
{this.makeItems(NUM_ITEMS, [
|
||||||
|
|
|
@ -73,9 +73,10 @@ public class ReactHorizontalScrollViewManager
|
||||||
}
|
}
|
||||||
|
|
||||||
@ReactProp(name = "snapToInterval")
|
@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();
|
DisplayMetrics screenDisplayMetrics = DisplayMetricsHolder.getScreenDisplayMetrics();
|
||||||
view.setSnapInterval((int)(snapToInterval * screenDisplayMetrics.density));
|
view.setSnapInterval((int) (snapToInterval * screenDisplayMetrics.density));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ReactProp(name = ReactClippingViewGroupHelper.PROP_REMOVE_CLIPPED_SUBVIEWS)
|
@ReactProp(name = ReactClippingViewGroupHelper.PROP_REMOVE_CLIPPED_SUBVIEWS)
|
||||||
|
|
Loading…
Reference in New Issue