diff --git a/Examples/UIExplorer/ViewPagerAndroidExample.android.js b/Examples/UIExplorer/ViewPagerAndroidExample.android.js index 8dcbbb06ec67bc..e4f33458e95b36 100644 --- a/Examples/UIExplorer/ViewPagerAndroidExample.android.js +++ b/Examples/UIExplorer/ViewPagerAndroidExample.android.js @@ -96,23 +96,39 @@ var ViewPagerAndroidExample = React.createClass({ description: 'Container that allows to flip left and right between child views.' }, getInitialState: function() { - return {page: 0, progress: {position: 0, offset: 0}}; + return { + page: 0, + animationsAreEnabled: true, + progress: { + position: 0, + offset: 0, + }, + }; }, + onPageSelected: function(e) { this.setState({page: e.nativeEvent.position}); }, + onPageScroll: function(e) { this.setState({progress: e.nativeEvent}); }, + move: function(delta) { var page = this.state.page + delta; - this.viewPager && this.viewPager.setPage(page); - this.setState({page}); + this.go(page); }, + go: function(page) { - this.viewPager && this.viewPager.setPage(page); + if (this.state.animationsAreEnabled) { + this.viewPager.setPage(page); + } else { + this.viewPager.setPageWithoutAnimation(page); + } + this.setState({page}); }, + render: function() { var pages = []; for (var i = 0; i < PAGES; i++) { @@ -131,7 +147,7 @@ var ViewPagerAndroidExample = React.createClass({ ); } - var page = this.state.page; + var { page, animationsAreEnabled } = this.state; return ( { this.viewPager = viewPager; }}> {pages} + + { animationsAreEnabled ? +