add peeking feature in AndroidViewPage(RN)

Reviewed By: sahrens

Differential Revision: D5340198

fbshipit-source-id: b2986a320a39225882d4289b193e1d22e9e7547e
This commit is contained in:
Kaibin Yin 2017-06-30 22:18:22 -07:00 committed by Facebook Github Bot
parent ecd5829bf8
commit c42080eaaf
2 changed files with 12 additions and 0 deletions

View File

@ -75,6 +75,7 @@ class ViewPagerAndroid extends React.Component {
onPageScrollStateChanged?: Function,
onPageSelected?: Function,
pageMargin?: number,
peekEnabled?: boolean,
keyboardDismissMode?: 'none' | 'on-drag',
scrollEnabled?: boolean,
};
@ -137,6 +138,12 @@ class ViewPagerAndroid extends React.Component {
* The default value is true.
*/
scrollEnabled: PropTypes.bool,
/**
* Whether enable showing peekFraction or not. If this is true, the preview of
* last and next page will show in current screen. Defaults to false.
*/
peekEnabled: PropTypes.bool,
};
componentDidMount() {

View File

@ -120,4 +120,9 @@ public class ReactViewPagerManager extends ViewGroupManager<ReactViewPager> {
public void setPageMargin(ReactViewPager pager, float margin) {
pager.setPageMargin((int) PixelUtil.toPixelFromDIP(margin));
}
@ReactProp(name = "peekEnabled", defaultBoolean = false)
public void setPeekEnabled(ReactViewPager pager, boolean peekEnabled) {
pager.setClipToPadding(!peekEnabled);
}
}