Skip to content

Commit

Permalink
Adding support to float values for Android snapToInterval
Browse files Browse the repository at this point in the history
Reviewed By: fkgozali

Differential Revision: D6684529

fbshipit-source-id: 51efa0a2d38acf4134bb824c462973e5c6bdf17a
  • Loading branch information
mdvacca authored and facebook-github-bot committed Jan 9, 2018
1 parent a8d4666 commit b2848a5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion RNTester/js/ScrollViewSimpleExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class ScrollViewSimpleExample extends React.Component<{}> {
<ScrollView
key={'scrollViewSnap'}
horizontal
snapToInterval={210}
snapToInterval={210.0}
pagingEnabled
>
{this.makeItems(NUM_ITEMS, [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ public void setShowsHorizontalScrollIndicator(ReactHorizontalScrollView view, bo
}

@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)
Expand Down

0 comments on commit b2848a5

Please sign in to comment.