Skip to content

Commit

Permalink
Merge pull request #61 from almost/master
Browse files Browse the repository at this point in the history
Support index property in combination with loop property
  • Loading branch information
leecade committed Dec 22, 2015
2 parents 4636c62 + 85b6e94 commit e28af9b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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',
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e28af9b

Please sign in to comment.