Skip to content

Commit

Permalink
Merge pull request #541 from kjkta/master
Browse files Browse the repository at this point in the history
Calculate the offset in the initial state instead of `onLayout`.
  • Loading branch information
Bart Arribe authored Sep 6, 2017
2 parents 00e4050 + 1fb7ff2 commit a8e052c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ export default class extends Component {

const initState = {
autoplayEnd: false,
loopJump: false
loopJump: false,
offset: {}
}

initState.total = props.children ? props.children.length || 1 : 0
Expand All @@ -224,6 +225,9 @@ export default class extends Component {
initState.dir = props.horizontal === false ? 'y' : 'x'
initState.width = props.width || width
initState.height = props.height || height
initState.offset[initState.dir] = initState.dir === 'y'
? height * props.index
: width * props.index

this.internals = {
...this.internals,
Expand Down

0 comments on commit a8e052c

Please sign in to comment.