]> _ Git - fluidbook-html5.git/commitdiff
wip #4448 @4
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 10 May 2021 06:15:44 +0000 (08:15 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 10 May 2021 06:15:44 +0000 (08:15 +0200)
js/libs/fluidbook/fluidbook.3dflip.js
js/libs/fluidbook/fluidbook.loader.js
style/fluidbook.less

index eaf67edd51db2cfcd645b412cd2ea182e1e31e5c..31c54ae18b01540ccd353d408281d48a40907b51 100644 (file)
@@ -458,8 +458,8 @@ Fluidbook3DFlip.prototype = {
         this.prepareTexture(turning.flip[1], function (t1) {
             $this.prepareTexture(turning.flip[0], function (t2) {
                 $this.texturesLoaded(t1, t2, turning.dir, callback);
-            });
-        })
+            }, turning.dir > 0);
+        }, turning.dir < 0);
     },
 
     getPerformancesTestResult: function () {
@@ -586,15 +586,18 @@ Fluidbook3DFlip.prototype = {
         }
     },
 
-    prepareTexture: function (page, callback) {
+    prepareTexture: function (page, callback, enter) {
         if (null === THREE) {
             return;
         }
+        if (enter === undefined) {
+            enter = true;
+        }
         this.fluidbook.loader.getTexture(page, function (image) {
             var texture = new THREE.Texture(image);
             texture.needsUpdate = true;
             callback(texture);
-        });
+        }, enter);
     },
 
     initTurn: function (dir) {
index c6445e02e356ee8a67e9fd6eb79b2cc1d4948dac..cfb26b0e30d9fe7b510f95c057b09581c0d2b231 100644 (file)
@@ -166,7 +166,13 @@ FluidbookLoader.prototype = {
 
         if (this.fluidbook.pagetransitions.flip3d !== false) {
             $_callback = function () {
-                $this.loadTexture(page, callback);
+                $this.loadTexture(page, function () {
+                    if ($this.needSeparateTextures(page)) {
+                        $this.loadTexture(page, callback, false);
+                    } else {
+                        callback();
+                    }
+                }, true);
             };
         } else {
             $_callback = callback;
@@ -424,7 +430,8 @@ FluidbookLoader.prototype = {
         this.backgrounds[page] = this.loadImage(url, null, null, null, page, callback);
     },
     needSeparateTextures: function (page) {
-        return this.fluidbook.settings.clinks[page].indexOf('data-animation-hide') >= 0;
+        return this.fluidbook.settings.clinks[page].indexOf('data-animation-hide') >= 0 ||
+            this.fluidbook.settings.clinks[page].indexOf('data-animation-hide-on-leave') >= 0;
     },
     loadTexture: function (page, callback, enter) {
         if (enter === undefined) {
@@ -439,7 +446,10 @@ FluidbookLoader.prototype = {
         }
 
 
-        if (this.textures[page] !== undefined && this.textures[page] !== null) {
+        if (
+            (enter && this.textures[page] !== undefined && this.textures[page] !== null) ||
+            (!enter && this.leaveTextures[page] !== undefined && this.leaveTextures[page] !== null)
+        ) {
             callback();
         } else {
             try {
@@ -467,7 +477,7 @@ FluidbookLoader.prototype = {
             }
         };
         $('.texture_clinks[data-page="' + page + '"] .contentLink[data-image]').each(function () {
-            if (enter && $(this).data('animation-hide')) {
+            if ((enter && $(this).is('[data-animation-hide]')) || (!enter && $(this).is('[data-animation-hide-on-leave]'))) {
                 return;
             }
             nb++;
@@ -491,7 +501,7 @@ FluidbookLoader.prototype = {
         }
         var $this = this;
         var clinks = this.handleExtension(this.fluidbook.settings.clinks[page]);
-        this._preloadContentLinkTextures(page,clinks, enter, function (textures) {
+        this._preloadContentLinkTextures(page, clinks, enter, function (textures) {
             var d = 1024;
             var c = document.getElementById("pscanvas");
             c.width = d;
@@ -527,7 +537,7 @@ FluidbookLoader.prototype = {
 
             if (clinks !== '') {
                 $('.texture_clinks[data-page="' + page + '"] .contentLink').each(function () {
-                    if (enter && $(this).data('animation-hide')) {
+                    if ((enter && $(this).is('[data-animation-hide]')) || (!enter && $(this).is('[data-animation-hide-on-leave]'))) {
                         return;
                     }
                     var left = parseFloat($(this).css('left')) * wr;
@@ -568,22 +578,30 @@ FluidbookLoader.prototype = {
 
             var i = new Image();
             i.onload = function () {
-                $this.textures[page] = i;
+                if (enter) {
+                    $this.textures[page] = i;
+                } else {
+                    $this.leaveTextures[page] = i;
+                }
                 callback();
             }
             i.src = c.toDataURL("image/png");
         });
     },
 
-    getTexture: function (page, callback) {
+    getTexture: function (page, callback, enter) {
+        if (enter === undefined) {
+            enter = true;
+        }
         var $this = this;
+        var t = enter || !this.needSeparateTextures(page) ? 'textures' : 'leaveTextures';
 
-        if (this.textures[page] === undefined) {
+        if (this[t][page] === undefined || this[t][page] === null) {
             this._preloadPage(page, function () {
-                callback($this.textures[page]);
+                callback($this[t][page]);
             });
         } else {
-            callback(this.textures[page]);
+            callback(this[t][page]);
         }
     },
 
index ca612119f60a669ee40f25b2fe8f520c877bbabf..5f4fb5c45d51834de154c6e57157333b236750e9 100644 (file)
@@ -3051,7 +3051,7 @@ body > input {
   display: none;
 }
 
-.textures_clinks {
+.texture_clinks {
   visibility: hidden;
 }