]> _ Git - fluidbook-html5.git/commitdiff
wait #3612 @2
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 23 Apr 2020 17:37:22 +0000 (19:37 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 23 Apr 2020 17:37:22 +0000 (19:37 +0200)
_index.html
js/libs/fluidbook/fluidbook.js
js/libs/fluidbook/fluidbook.splash.js [new file with mode: 0644]

index 1d662a7f6e9a296860e3a77f0ad04e0b825552af..d3c3c10fb9fe56b248ffcc69ae1381c1065b4b00 100644 (file)
@@ -97,7 +97,7 @@
 <canvas id="pscanvas" width="4096" height="4096"></canvas>
 <div id="loader"></div>
 <div id="hiddencontents"><!-- $hiddenContents --></div>
-<div id="splash" style="background-color:#<!-- $bgcolor -->;"><!-- $splash --></div>
+<div id="splash" style="background-color:#<!-- $bgcolor -->;<!-- $splashstyles -->"><!-- $splash --></div>
 <div id="popinOverlay"></div>
 <div id="landingPage"></div>
 <div id="loadedcontents"></div>
index 739fc118a2096cd58767eaa474edb3e0be375006..95bc1b0a128a591963a277ae519e2b112f6fb2bd 100644 (file)
@@ -41,6 +41,7 @@ Fluidbook.prototype = {
             this.landingpage = new FluidbookLandingPage(this);
         }
 
+        this.splash = new FluidbookSplash(this);
         this.contentlock = new FluidbookContentLock(this);
         this.menu = new FluidbookMenu(this);
         this.support = new FluidbookSupport(this);
@@ -73,6 +74,7 @@ Fluidbook.prototype = {
         this.slideshow = new FluidbookSlideshow(this);
         this.printing = new FluidbookPrint(this);
 
+
         if (this.settings.basket) {
             this.cart = new FluidbookCart(this);
         }
@@ -209,64 +211,6 @@ Fluidbook.prototype = {
         });
         // See fluidbook.audiodescription.js for specific shortcuts
     },
-    hideSplash: function () {
-        if ($("#splash").length == 0) {
-            return;
-        }
-        try {
-            navigator.splashscreen.hide();
-        } catch (err) {
-        }
-        $(this).trigger('fluidbook.splash.beforehide');
-        var $this = this;
-        if (this.support.transitions3dacc && this.settings.mobileTransitions === 'flip3d' && !this.mobilefirst.enabled) {
-            $("#main,#viewOverlay,#view").css('visibility', 'visible');
-            resize();
-            this.networkControl.pause(4000);
-            setTimeout(function () {
-                this.fluidbook.pagetransitions.flip3d.performancesTest(function () {
-                    $this.networkControl.resume();
-                    $this._hideSplash();
-                })
-            }, 500);
-        } else {
-            this._hideSplash();
-        }
-    },
-
-
-    _hideSplash: function () {
-        var $this = this;
-        var timeout = 700;
-        this.resize.resize(false, true);
-        setTimeout(function () {
-            $this.__hideSplash();
-        }, timeout);
-    },
-
-    __hideSplash: function () {
-
-        $("#main,#viewOverlay,#view").css('visibility', 'visible');
-        this.resize.resize(false);
-        this.hideLoader(0, true);
-
-        if (this.support.transitions2d && !this.support.iOS) {
-            $("#splash").css('opacity', 0).one('transitionend', function () {
-                $(this).remove();
-            });
-        } else {
-            $("#splash").fadeOut(500, function () {
-                $(this.remove());
-            })
-        }
-
-        setTimeout(function () {
-            $("#splash").remove();
-        }, 1500);
-
-        this.allowChangePage();
-        $(this).trigger('fluidbook.splash.hide');
-    },
 
     allowChangePage: function () {
         var $this = this;
@@ -502,10 +446,10 @@ Fluidbook.prototype = {
                 }
                 $this.zoom.resetZoom();
 
-                $this.hideSplash();
+                $this.splash.hide();
             }, true);
         } else if (args[1] === 'landing') {
-            $this.hideSplash();
+            $this.splash.hide();
             if (this.landingpage !== undefined) {
                 this.landingpage.show();
             }
@@ -531,7 +475,7 @@ Fluidbook.prototype = {
                 $this.pagetransitions.pageTransition(this.currentPage);
             }
             this.menu.openView(view, args[2], args[3], function () {
-                $this.hideSplash();
+                $this.splash.hide();
             });
         }
         return;
diff --git a/js/libs/fluidbook/fluidbook.splash.js b/js/libs/fluidbook/fluidbook.splash.js
new file mode 100644 (file)
index 0000000..f2e4db4
--- /dev/null
@@ -0,0 +1,85 @@
+function FluidbookSplash(fluidbook) {
+    this.fluidbook = fluidbook;
+    this.init();
+}
+
+FluidbookSplash.prototype = {
+    init: function () {
+        this.waitForTimer = true;
+        this.waitForReady = true;
+
+        var $this = this;
+        this.initTime = Date.now();
+        setTimeout(function () {
+            $this.waitForTimer = false;
+            $this.hideIfPossible();
+        }, parseFloat(this.fluidbook.settings.splashMinimalTime) * 1000);
+
+    },
+
+    hide: function () {
+        if ($("#splash").length == 0) {
+            return;
+        }
+        this.waitForReady = false;
+        try {
+            navigator.splashscreen.hide();
+        } catch (err) {
+        }
+        $(this.fluidbook).trigger('fluidbook.splash.beforehide');
+        var $this = this;
+        if (this.fluidbook.support.transitions3dacc && this.fluidbook.settings.mobileTransitions === 'flip3d' && !this.fluidbook.mobilefirst.enabled) {
+            $("#main,#viewOverlay,#view").css('visibility', 'visible');
+            resize();
+            this.fluidbook.networkControl.pause(4000);
+            setTimeout(function () {
+                this.fluidbook.pagetransitions.flip3d.performancesTest(function () {
+                    $this.fluidbook.networkControl.resume();
+                    $this.hideIfPossible();
+                })
+            }, 500);
+        } else {
+            this.hideIfPossible();
+        }
+    },
+
+    hideIfPossible: function () {
+        if (!this.waitForReady && !this.waitForTimer) {
+            this._hide();
+        }
+    },
+
+    _hide: function () {
+        var $this = this;
+        var timeout = 700;
+        this.fluidbook.resize.resize(false, true);
+        setTimeout(function () {
+            $this.__hide();
+        }, timeout);
+    },
+
+    __hide: function () {
+
+        $("#main,#viewOverlay,#view").css('visibility', 'visible');
+        this.fluidbook.resize.resize(false);
+        this.fluidbook.hideLoader(0, true);
+
+        if (this.fluidbook.support.transitions2d && !this.fluidbook.support.iOS) {
+            $("#splash").css('opacity', 0).one('transitionend', function () {
+                $(this).remove();
+            });
+        } else {
+            $("#splash").fadeOut(500, function () {
+                $(this.remove());
+            })
+        }
+
+        setTimeout(function () {
+            $("#splash").remove();
+        }, 1500);
+
+        this.fluidbook.allowChangePage();
+        $(this.fluidbook).trigger('fluidbook.splash.hide');
+    },
+
+}
\ No newline at end of file