From 5555cae1789193fadad157a9c2c558541592df80 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Mon, 21 Jan 2019 17:22:52 +0100 Subject: [PATCH] fix #2522 @4 --- js/libs/fluidbook/fluidbook.3dflip.js | 45 +++++++++++-------- .../fluidbook/fluidbook.pagetransitions.js | 15 ++++--- 2 files changed, 35 insertions(+), 25 deletions(-) diff --git a/js/libs/fluidbook/fluidbook.3dflip.js b/js/libs/fluidbook/fluidbook.3dflip.js index 882d52a2..749480d1 100644 --- a/js/libs/fluidbook/fluidbook.3dflip.js +++ b/js/libs/fluidbook/fluidbook.3dflip.js @@ -439,7 +439,7 @@ Fluidbook3DFlip.prototype = { this.prepareTexture(turning.flip[1], function (t1) { $this.prepareTexture(turning.flip[0], function (t2) { - $this.texturesLoaded(t1, t2, callback); + $this.texturesLoaded(t1, t2, turning.dir, callback); }); }) }, @@ -527,13 +527,13 @@ Fluidbook3DFlip.prototype = { } }, - texturesLoaded: function (t1, t2, callback) { + texturesLoaded: function (t1, t2, dir, callback) { if (this.textures === undefined || this.textures === null || this.textures.length === 0) { // If textures are not loaded console.warn('Texture object not ready. Waiting'); var $this = this; setTimeout(function () { - $this.texturesLoaded(t1, t2, callback); + $this.texturesLoaded(t1, t2, dir, callback); }, 500); return; } @@ -550,6 +550,7 @@ Fluidbook3DFlip.prototype = { this.ready = true; this.resize(); + callback(); }, @@ -571,16 +572,7 @@ Fluidbook3DFlip.prototype = { callback(texture); }, - playTurn: function (dir, callback, timeScale, delay) { - if (this.turnRunning) { - return; - } - if (timeScale === undefined) { - timeScale = 1; - } - - var $this = this; - + initTurn: function (dir) { this.turnRunning = true; this.tlname = dir === 1 ? 'right' : 'left'; @@ -591,12 +583,24 @@ Fluidbook3DFlip.prototype = { this.progressAnimation(0); this.animate(false); + this.resize(); + }, + + playTurn: function (dir, callback, timeScale, delay) { + if (!this.turnRunning) { + this.initTurn(dir); + } + + if (timeScale === undefined) { + timeScale = 1; + } + + var $this = this; + if (delay === undefined) { delay = this.fluidbook.support.iOS ? 0.15 : 0.06; } - this.resize(); - TweenMax.fromTo(this, this.animationTime * timeScale, {progressAnimation: 0,}, { @@ -626,24 +630,25 @@ Fluidbook3DFlip.prototype = { }); } - var render = true; + var visible; if (this._progressAnimation < 1) { if (this.turnRunning) { if (this.performancesTestRunning) { this.performancesFrames++; } render = true; - this.setJContainerVisibility(true); + visible = true; } else { render = false; - this.setJContainerVisibility(false); + visible = false; } } else { render = false; - this.setJContainerVisibility(false); + visible = false; } + if (render) { var d = ((720 + this._pageRotation) % 360); this.plane.rotation.y = d * this.deg2rad; @@ -651,6 +656,8 @@ Fluidbook3DFlip.prototype = { this.modifier && this.modifier.apply(); } + this.setJContainerVisibility(visible); + if (this._callbackAfterNextRender !== null) { try { var c = this._callbackAfterNextRender; diff --git a/js/libs/fluidbook/fluidbook.pagetransitions.js b/js/libs/fluidbook/fluidbook.pagetransitions.js index 6677e472..e98574ba 100644 --- a/js/libs/fluidbook/fluidbook.pagetransitions.js +++ b/js/libs/fluidbook/fluidbook.pagetransitions.js @@ -168,14 +168,17 @@ FluidbookPageTransition.prototype = { this.fluidbook.loader.preloadPagesBeforeTransition(turning.end, function () { $this.flip3d.clean(); $this.flip3d.prepareTurn(turning, function () { - $this.fluidbook.loader.setContentsInDoublePage(currentDoublePage, turning.flat, true, function () { - $this.beforeTransition(pageNr, 3, turning); - $this.flip3d.playTurn(turning.dir, function () { - $this.fluidbook.loader.setContentsInDoublePage(currentDoublePage, turning.end, true, function () { - $this.afterTransition(pageNr); + $this.beforeTransition(pageNr, 3, turning); + $this.flip3d.initTurn(turning.dir); + setTimeout(function(){ + $this.fluidbook.loader.setContentsInDoublePage(currentDoublePage, turning.flat, true, function () { + $this.flip3d.playTurn(turning.dir, function () { + $this.fluidbook.loader.setContentsInDoublePage(currentDoublePage, turning.end, true, function () { + $this.afterTransition(pageNr); + }); }); }); - }); + },10); }); }); }, -- 2.39.5