|
var ViewPagerAndroid = function (_React$Component) { |
|
babelHelpers.inherits(ViewPagerAndroid, _React$Component); |
|
|
|
function ViewPagerAndroid() { |
|
var _ref; |
|
|
|
var _temp, _this2, _ret; |
|
|
|
babelHelpers.classCallCheck(this, ViewPagerAndroid); |
|
|
|
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { |
|
args[_key] = arguments[_key]; |
|
} |
|
|
|
return _ret = (_temp = (_this2 = babelHelpers.possibleConstructorReturn(this, (_ref = ViewPagerAndroid.__proto__ || Object.getPrototypeOf(ViewPagerAndroid)).call.apply(_ref, [this].concat(args))), _this2), _this2.getInnerViewNode = function () { |
|
return _this.refs[VIEWPAGER_REF].getInnerViewNode(); |
|
}, _this2._childrenWithOverridenStyle = function () { |
|
// Override styles so that each page will fill the parent. Native component |
|
// will handle positioning of elements, so it's not important to offset |
|
// them correctly. |
|
return React.Children.map(_this.props.children, function (child) { |
|
if (!child) { |
|
return null; |
|
} |
|
var newProps = babelHelpers.extends({}, child.props, { |
|
style: [child.props.style, { |
|
position: 'absolute', |
|
left: 0, |
|
top: 0, |
|
right: 0, |
|
bottom: 0, |
|
width: undefined, |
|
height: undefined |
|
}], |
|
collapsable: false |
|
}); |
|
if (child.type && child.type.displayName && child.type.displayName !== 'RCTView' && child.type.displayName !== 'View') { |
|
console.warn('Each ViewPager child must be a <View>. Was ' + child.type.displayName); |
|
} |
|
return ReactElement.createElement(child.type, newProps); |
|
}); |
|
}, _this2._onPageScroll = function (e) { |
|
if (_this.props.onPageScroll) { |
|
_this.props.onPageScroll(e); |
|
} |
|
if (_this.props.keyboardDismissMode === 'on-drag') { |
|
dismissKeyboard(); |
|
} |
|
}, _this2._onPageScrollStateChanged = function (e) { |
|
if (_this.props.onPageScrollStateChanged) { |
|
_this.props.onPageScrollStateChanged(e.nativeEvent.pageScrollState); |
|
} |
|
}, _this2._onPageSelected = function (e) { |
|
if (_this.props.onPageSelected) { |
|
_this.props.onPageSelected(e); |
|
} |
|
}, _this2.setPage = function (selectedPage) { |
|
UIManager.dispatchViewManagerCommand(ReactNative.findNodeHandle(_this), UIManager.AndroidViewPager.Commands.setPage, [selectedPage]); |
|
}, _this2.setPageWithoutAnimation = function (selectedPage) { |
|
UIManager.dispatchViewManagerCommand(ReactNative.findNodeHandle(_this), UIManager.AndroidViewPager.Commands.setPageWithoutAnimation, [selectedPage]); |
|
}, _temp), babelHelpers.possibleConstructorReturn(_this2, _ret); |
|
} |
|
|
|
babelHelpers.createClass(ViewPagerAndroid, [{ |
|
key: 'componentDidMount', |
|
value: function componentDidMount() { |
|
if (this.props.initialPage) { |
|
this.setPageWithoutAnimation(this.props.initialPage); |
|
} |
|
} |
|
|
|
/** |
|
* A helper function to scroll to a specific page in the ViewPager. |
|
* The transition between pages will be animated. |
|
*/ |
|
|
|
|
|
/** |
|
* A helper function to scroll to a specific page in the ViewPager. |
|
* The transition between pages will *not* be animated. |
|
*/ |
|
|
|
}, { |
|
key: 'render', |
|
value: function render() { |
|
return React.createElement(NativeAndroidViewPager, babelHelpers.extends({}, this.props, { |
|
ref: VIEWPAGER_REF, |
|
style: this.props.style, |
|
onPageScroll: this._onPageScroll, |
|
onPageScrollStateChanged: this._onPageScrollStateChanged, |
|
onPageSelected: this._onPageSelected, |
|
children: this._childrenWithOverridenStyle() |
|
})); |
|
} |
|
}]); |
|
return ViewPagerAndroid; |
|
}(React.Component); |