Skip to content

Commit

Permalink
Calcuate the offset in the initial state.
Browse files Browse the repository at this point in the history
Enables the inital index to be rendered first, avoiding a render of uncalculated offset.
  • Loading branch information
kjkta committed Aug 27, 2017
1 parent 653f98b commit 1fb7ff2
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 1fb7ff2

Please sign in to comment.