]> _ Git - fluidbook-html5.git/commitdiff
wip #2649 @3
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 26 Mar 2019 13:57:55 +0000 (14:57 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 26 Mar 2019 13:57:55 +0000 (14:57 +0100)
js/libs/fluidbook/fluidbook.js
js/libs/fluidbook/fluidbook.loader.js
js/libs/fluidbook/fluidbook.pagetransitions.js

index 1a8e0d979006ef21b02021a80b4fff160f0be9f9..4541d0324c4a719bb1bfd0394282d75d0ba8b093 100644 (file)
@@ -21,16 +21,16 @@ Fluidbook.prototype = {
     init: function (datas) {
 
         this.flags = {};
-        this.networkPause = false;
-        this.networkPauseTimeout = null;
+        this.networkPauseDate = null;
         this.networkPauseQueue = [];
+        this.initNetworkPause();
         this.canNavigate = false;
 
         this.initSettings(datas);
         this.singleMode = (this.datas.mobileNavigationType === 'portrait');
 
         this.junk = datas.cacheDate;
-        this.input=new FluidbookInput(this);
+        this.input = new FluidbookInput(this);
         if (this.datas.landingPage != undefined && this.datas.landingPage != '') {
             this.landingpage = new FluidbookLandingPage(this);
         }
@@ -1071,30 +1071,39 @@ Fluidbook.prototype = {
     }
     ,
 
-    pauseNetwork: function (during) {
-        clearTimeout(this.networkPauseTimeout);
+    initNetworkPause: function () {
         var $this = this;
+        setInterval(function () {
+
+            if ($this.networkPauseDate != null && $this.networkPauseDate < Date.now()) {
+                $this.networkPauseDate = null;
+                $this.flushNetworkQueue();
+            }
+        }, 1000);
+    },
+
+    pauseNetwork: function (during) {
         if (during === -1) {
-            this.networkPause = false;
+            this.networkPauseDate = null;
             this.flushNetworkQueue();
             return;
         }
-        this.networkPause = true;
-        this.networkPauseTimeout = setTimeout(function () {
-            $this.networkPause = false;
-            $this.flushNetworkQueue();
-        }, during + 500)
-    }
-    ,
+
+        var date = Date.now() + during + 500;
+        if (this.networkPauseDate == null) {
+            this.networkPauseDate = date;
+        } else {
+            this.networkPauseDate = Math.max(this.networkPauseDate, date);
+        }
+    },
 
     executeWhenNetwork: function (f) {
-        if (this.networkPause) {
+        if (this.networkPauseDate != null) {
             this.networkPauseQueue.push(f);
             return;
         }
         f();
-    }
-    ,
+    },
 
     unlockCurrentPage: function () {
         this.contentlock.unlockCurrentPage();
@@ -1102,7 +1111,7 @@ Fluidbook.prototype = {
     ,
 
     flushNetworkQueue: function () {
-        if (this.networkPauseQueue.length === 0 || this.networkPause) {
+        if (this.networkPauseQueue.length === 0 || this.networkPauseDate != null) {
             return;
         }
 
index 2e9d7a347e768c8cabd2dced6b590f9d7e526a81..43c7510751ef74d93b7fb763c3032f5b9cf3736a 100644 (file)
@@ -40,6 +40,11 @@ FluidbookLoader.prototype = {
     },
 
     preloadPagesBeforeTransition: function (pages, callback) {
+        if (this.arePreloadedPages(pages)) {
+            callback();
+            return;
+        }
+
         var $this = this;
         var $pages = pages.slice(0);
         if ($pages.length == 0) {
@@ -207,7 +212,7 @@ FluidbookLoader.prototype = {
             });
         } else {
             this.loadLeftPage(leftPage, $(doublePage), function () {
-            })
+            });
             this.loadRightPage(rightPage, $(doublePage), function () {
             });
             callback();
index 668592ccdb09ad929b584aee87333bcc77b2da29..3c58556f1aff02550171696c21a4420c69abc32a 100644 (file)
@@ -112,7 +112,7 @@ FluidbookPageTransition.prototype = {
         }
     },
     pageTransition3D: function (pageNr) {
-        console.log(this.transitionning);
+
         var $this = this;
         if ($("#pages").hasClass('_3dtransition')) {
             return;
@@ -171,7 +171,6 @@ FluidbookPageTransition.prototype = {
         $("#pages").prepend('<div id="nextDoublePage" class="_3d doublePage"></div>');
         var doublePage = $("#nextDoublePage");
 
-
         this.fluidbook.loader.preloadPagesBeforeTransition(turning.end, function () {
             $this.flip3d.clean();
             $this.flip3d.prepareTurn(turning, function () {
@@ -181,7 +180,7 @@ FluidbookPageTransition.prototype = {
                     $this.fluidbook.loader.setContentsInDoublePage(currentDoublePage, turning.flat, true, function () {
                         $this.flip3d.playTurn(turning.dir, function () {
                             $this.fluidbook.loader.setContentsInDoublePage(doublePage, turning.end, true, function () {
-                                if ($this.transitionning == false) {
+                                if ($this.transitionning === false) {
                                     return;
                                 }
                                 // Remove former part
@@ -388,7 +387,7 @@ FluidbookPageTransition.prototype = {
         }, 1000 * (animationDuration + 2))
 
         try {
-            this.search.clearHighlights();
+            this.fluidbook.search.clearHighlights();
         } catch (err) {
 
         }