From 1fb7ff24cf2adb3bbe2feb487e9ac88c97c603a6 Mon Sep 17 00:00:00 2001 From: Kyle Thomson Date: Sun, 27 Aug 2017 17:22:44 +0200 Subject: [PATCH] Calcuate the offset in the initial state. Enables the inital index to be rendered first, avoiding a render of uncalculated offset. --- src/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 743cccdd..26d0c177 100644 --- a/src/index.js +++ b/src/index.js @@ -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 @@ -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,