]> _ Git - fluidbook-html5.git/commitdiff
fix #2522 @4
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 21 Jan 2019 16:22:52 +0000 (17:22 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 21 Jan 2019 16:22:52 +0000 (17:22 +0100)
js/libs/fluidbook/fluidbook.3dflip.js
js/libs/fluidbook/fluidbook.pagetransitions.js

index 882d52a24eed2089e5ae88e20707260c53d61d0a..749480d168ab35123e0f05584861e5a69aaa2807 100644 (file)
@@ -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;
index 6677e472235b4bf5a0f6aa2d9de4d8686540e557..e98574ba5d6f03a8fc59e8b70bd157588bd3e140 100644 (file)
@@ -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);
             });
         });
     },