mirror of
https://github.com/zhigang1992/react-native-swiper.git
synced 2026-01-12 17:42:56 +08:00
Merge pull request #61 from almost/master
Support index property in combination with loop property
This commit is contained in:
13
dist/index.js
vendored
13
dist/index.js
vendored
@@ -14,14 +14,14 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'd
|
||||
|
||||
var _reactNative = require('react-native');
|
||||
|
||||
var _reactNative2 = _interopRequireDefault(_reactNative);
|
||||
|
||||
// Using bare setTimeout, setInterval, setImmediate
|
||||
// and requestAnimationFrame calls is very dangerous
|
||||
// because if you forget to cancel the request before
|
||||
// the component is unmounted, you risk the callback
|
||||
// throwing an exception.
|
||||
|
||||
var _reactNative2 = _interopRequireDefault(_reactNative);
|
||||
|
||||
var _reactTimerMixin = require('react-timer-mixin');
|
||||
|
||||
var _reactTimerMixin2 = _interopRequireDefault(_reactTimerMixin);
|
||||
@@ -32,12 +32,13 @@ var _Dimensions2 = _interopRequireDefault(_Dimensions);
|
||||
|
||||
var _Dimensions$get = _Dimensions2['default'].get('window');
|
||||
|
||||
var width = _Dimensions$get.width;
|
||||
var height = _Dimensions$get.height;
|
||||
|
||||
/**
|
||||
* Default styles
|
||||
* @type {StyleSheetPropType}
|
||||
*/
|
||||
var width = _Dimensions$get.width;
|
||||
var height = _Dimensions$get.height;
|
||||
var styles = _reactNative.StyleSheet.create({
|
||||
container: {
|
||||
backgroundColor: 'transparent',
|
||||
@@ -204,7 +205,7 @@ exports['default'] = _reactNative2['default'].createClass({
|
||||
newState.offset = {};
|
||||
|
||||
if (newState.total > 1) {
|
||||
var setup = this.props.loop ? 1 : newState.index;
|
||||
var setup = this.props.loop ? newState.index + 1 : newState.index;
|
||||
newState.offset[this.state.dir] = this.state.dir == 'y' ? this.state.height * setup : this.state.width * setup;
|
||||
}
|
||||
|
||||
@@ -519,7 +520,7 @@ exports['default'] = _reactNative2['default'].createClass({
|
||||
}] },
|
||||
_reactNative2['default'].createElement(
|
||||
_reactNative.ScrollView,
|
||||
_extends({ ref: "scrollView"
|
||||
_extends({ ref: 'scrollView'
|
||||
}, props, {
|
||||
contentContainerStyle: [styles.wrapper, props.style],
|
||||
contentOffset: state.offset,
|
||||
|
||||
@@ -195,7 +195,7 @@ export default React.createClass({
|
||||
newState.offset = {}
|
||||
|
||||
if(newState.total > 1) {
|
||||
let setup = this.props.loop ? 1 : newState.index
|
||||
let setup = this.props.loop ? newState.index + 1 : newState.index
|
||||
newState.offset[this.state.dir] = this.state.dir == 'y'
|
||||
? this.state.height * setup
|
||||
: this.state.width * setup
|
||||
|
||||
Reference in New Issue
Block a user