]> _ Git - fluidbook-html5.git/commitdiff
wip #7418 @1.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 27 Mar 2025 16:42:21 +0000 (17:42 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 27 Mar 2025 16:42:21 +0000 (17:42 +0100)
js/libs/fluidbook/fluidbook.3dflip.js
js/libs/fluidbook/fluidbook.js
js/libs/fluidbook/fluidbook.loader.js
js/libs/fluidbook/fluidbook.splash.js
style/flip3d.less

index ad520d2bbc59d887f3b159b21392f4c904923ec4..8af7250722ee3c2f8e5afe24c13ab1969e7155ad 100644 (file)
@@ -415,21 +415,34 @@ Fluidbook3DFlip.prototype = {
         var _cb;
         var $this = this;
         var timeScale = 1;
+        $('body').addClass('perftest');
 
-        if (this.performancesMode !== 'performancesTest') {
-            console.log('no perf test');
-            _cb = callback;
-            timeScale = 0.1;
-        } else {
+        if (this.fluidbook.shortLoading) {
+            console.log('No perf test', (Date.now() - $this.fluidbook.splash.initDate) / 1000)
+            callback();
+            timeScale = 0.01;
             _cb = function () {
-                $this.performancesEndTime = new Date();
-                $this.adjustPerformancesSettings(callback);
+                console.log('After first fake turn', (Date.now() - $this.fluidbook.splash.initDate) / 1000)
+            };
+        } else {
+            if (this.performancesMode !== 'performancesTest') {
+                console.log('no perf test');
+                _cb = function () {
+                    callback();
+                }
+                timeScale = 0.01;
+            } else {
+                _cb = function () {
+                    $this.performancesEndTime = new Date();
+                    $this.adjustPerformancesSettings(callback);
+                }
             }
         }
 
         this.prepareTurn({flip: [1, 2]}, function () {
             $this.playTurn(1, function () {
                 _cb();
+                $('body').removeClass('perftest');
             }, timeScale);
         });
     },
@@ -578,16 +591,20 @@ Fluidbook3DFlip.prototype = {
 
         gsap.fromTo(this, {progressAnimation: 0,}, {
             duration: this.animationTime * timeScale,
-            progressAnimation: 1, ease: 'power0.in', delay: delay, onStart: function () {
+            progressAnimation: 1,
+            ease: 'power0.in',
+            delay: delay,
+            onStart: function () {
                 if ($this.performancesTestRunning) {
                     $this.performancesStartTime = new Date();
                 }
-            }, onComplete: function () {
+            },
+            onComplete: function () {
                 this.tlname = '';
                 callback();
                 setTimeout(function () {
                     $this.turnRunning = false;
-                }, 5);
+                }, 4);
                 //$this._callbackAfterNextRender = callback;
             }
         });
index ee41027acefacf6620f3994eaad174ab3a5eccea..7fe916ce537f3bc048782f51d64ccfbb85f84b67 100644 (file)
@@ -23,7 +23,7 @@ Fluidbook.prototype = {
         this.secureOKDone = false;
         this.initEventsWhenSecureOK = false;
         this.canNavigate = false;
-        this.shortLoading = false;
+        this.shortLoading = settings.shortLoading;
         this.nointerface = false;
         this.hideBook = false;
 
@@ -854,7 +854,7 @@ Fluidbook.prototype = {
         var pdfName;
 
         if (this.settings.pages != this.contentlock.getMaxPage()) {
-            pdf = this.service.getBaseURL(true) + 'e/'+this.settings.id+'-' + this.settings.cid + '/1-' + this.contentlock.getMaxPage();
+            pdf = this.service.getBaseURL(true) + 'e/' + this.settings.id + '-' + this.settings.cid + '/1-' + this.contentlock.getMaxPage();
         } else if (this.settings.pdfName.substr(0, 4) === 'http') {
             pdf = this.settings.pdfName;
         } else {
index aa338a2d198afeb02ce3ec421c2fdcd978ee8bba..3fe885153169c95262874f724dd1d44e533a3952 100644 (file)
@@ -289,10 +289,6 @@ FluidbookLoader.prototype = {
             numPreloadBefore = Math.ceil(numPreloadBefore / 2);
         }
 
-        if (this.fluidbook.shortLoading) {
-            numPreloadAfter = numPreloadBefore = 0;
-        }
-
         var fmx = this.fluidbook.contentlock.getMaxPage();
         var max = Math.min(page + numPreloadAfter, fmx);
         var min = Math.max(1, page - numPreloadBefore);
@@ -1276,7 +1272,7 @@ FluidbookLoader.prototype = {
                         clearInterval(interval);
                         callback(img);
                     }
-                }, 100);
+                }, $this.fluidbook.shortLoading ? 0 : 100);
             }
         });
 
index 41618a80292896185c684f912c0f24a79ae4365a..9004a8060f055e696cd5905822a4fc1bdc631bcb 100644 (file)
@@ -1,12 +1,16 @@
 function FluidbookSplash(fluidbook) {
     this.fluidbook = fluidbook;
-    this.hideSplashTimeout = 0.5;
+    this.hideSplashTimeout = fluidbook.shortLoading ? 0 : 0.5;
     this.isHidding = false;
+    this.initDate = Date.now();
     this.init();
 }
 
 FluidbookSplash.prototype = {
     init: function () {
+        var $this = this;
+        this.initTime = Date.now();
+
         this.waitForTimer = true;
         this.waitForReady = true;
 
@@ -26,18 +30,20 @@ FluidbookSplash.prototype = {
             this.hideIfPossible();
         }
 
-        var $this = this;
-        this.initTime = Date.now();
-        setTimeout(function () {
-            $this.waitForTimer = false;
-            $this.hideIfPossible();
-        }, min * 1000);
+
+        if (min > 0) {
+            setTimeout(function () {
+                $this.waitForTimer = false;
+                $this.hideIfPossible();
+            }, min * 1000);
+        }
     },
 
     hide: function () {
         if ($("#splash").length == 0) {
             return;
         }
+        console.log('Hide', (Date.now() - this.initDate) / 1000);
         this.waitForReady = false;
         try {
             navigator.splashscreen.hide();
@@ -50,14 +56,15 @@ FluidbookSplash.prototype = {
             resize();
             this.fluidbook.networkControl.pause(4000);
             setTimeout(function () {
-                this.fluidbook.pagetransitions.flip3d.performancesTest(function () {
+                $this.fluidbook.pagetransitions.flip3d.performancesTest(function () {
                     $this.fluidbook.networkControl.resume();
                     var timeout = $this.hideSplashTimeout;
+                    console.log('After performance test', timeout, (Date.now() - $this.initDate) / 1000)
                     setTimeout(function () {
                         $this.hideIfPossible();
                     }, timeout * 1000);
                 })
-            }, 500);
+            }, $this.fluidbook.shortLoading ? 4 : 500);
         } else {
             this.hideIfPossible();
         }
@@ -69,6 +76,7 @@ FluidbookSplash.prototype = {
 
     hideIfPossible: function () {
         if (!this.waitForReady && !this.waitForTimer) {
+            console.log('Hide if possible', (Date.now() - this.initDate) / 1000);
             this._hide();
         }
     },
@@ -87,11 +95,11 @@ FluidbookSplash.prototype = {
         $("#main,#viewOverlay,#view").css('visibility', 'visible');
         this.fluidbook.resize.resize(false);
         this.fluidbook.hideLoader(0, true);
-        this.fluidbook.networkControl.pause(1500);
+        if (!this.fluidbook.shortLoading) {
+            this.fluidbook.networkControl.pause(1500);
+        }
 
-        if (this.fluidbook.shortLoading) {
-            $('#splash').remove();
-        } else if (this.fluidbook.support.transitions2d && !this.fluidbook.support.iOS) {
+        if (this.fluidbook.support.transitions2d && !this.fluidbook.support.iOS) {
             $("#splash").css('opacity', 0).one('transitionend', function () {
                 $(this).remove();
             });
@@ -106,11 +114,13 @@ FluidbookSplash.prototype = {
 
         setTimeout(function () {
             $("#splash").remove();
+            $('body').removeClass('perftest');
         }, 1500);
 
         this.fluidbook.allowChangePage();
         $(this.fluidbook).trigger('fluidbook.splash.hide');
         this.isHidding = false;
+        console.log('Hide splash', (Date.now() - this.initDate) / 1000);
     },
 
 }
\ No newline at end of file
index a60590594708bfc95a17113397edaa80dd5c9f42..c51ed011b0e966354939b7d3ec738b36d00d5cc8 100644 (file)
@@ -1,4 +1,3 @@
-
 /* 3D Flip */
 
 #flip3dcontainer {
     position: relative;
     left: 0;
   }
+
+  .perftest & {
+    visibility: hidden !important;
+  }
 }
 
 .ios #pages {