From 6d96ecc4a2c6c7c01df76eb6ca24280ce0450db9 Mon Sep 17 00:00:00 2001 From: Naman Nehra Date: Fri, 14 Sep 2018 23:55:13 +0530 Subject: [PATCH] Performance improvement: Always render tunring element to avoid DOM mutation before animation --- src/Core/index.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Core/index.js b/src/Core/index.js index 246c798..871649a 100644 --- a/src/Core/index.js +++ b/src/Core/index.js @@ -14,11 +14,11 @@ class Core extends Component { const {children, className, horizontal, rootRef, selected, shadowBackground, ...otherProps} = this.props const direction = this.getDirection() const prev = children[Math.floor(selected)] - const next = children[Math.ceil(selected)] + const next = children[Math.floor(selected + 1)] const curr = children[Math.round(selected)] let turn = selected % 1 if (turn < 0) { - turn++ + turn -= Math.floor(turn) } let currPage = null if (curr && turn) { @@ -28,7 +28,7 @@ class Core extends Component { transform: `rotate${horizontal ? 'Y' : 'X'}(${rotation}deg)`, willChange: 'transform', } - const currShadowStyle = { + const shadowStyle = { background: shadowBackground, opacity: turn < 0.5 ? turn : 1 - turn, } @@ -53,7 +53,12 @@ class Core extends Component { {next} - {currPage} +
+
+ {curr} +
+
+
) }