From: Vincent Vanwaelscappel Date: Thu, 27 Mar 2025 16:42:21 +0000 (+0100) Subject: wip #7418 @1.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=72b20ed60c6acd0c9f11598e28088c559320268a;p=fluidbook-html5.git wip #7418 @1.5 --- diff --git a/js/libs/fluidbook/fluidbook.3dflip.js b/js/libs/fluidbook/fluidbook.3dflip.js index ad520d2b..8af72507 100644 --- a/js/libs/fluidbook/fluidbook.3dflip.js +++ b/js/libs/fluidbook/fluidbook.3dflip.js @@ -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; } }); diff --git a/js/libs/fluidbook/fluidbook.js b/js/libs/fluidbook/fluidbook.js index ee41027a..7fe916ce 100644 --- a/js/libs/fluidbook/fluidbook.js +++ b/js/libs/fluidbook/fluidbook.js @@ -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 { diff --git a/js/libs/fluidbook/fluidbook.loader.js b/js/libs/fluidbook/fluidbook.loader.js index aa338a2d..3fe88515 100644 --- a/js/libs/fluidbook/fluidbook.loader.js +++ b/js/libs/fluidbook/fluidbook.loader.js @@ -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); } }); diff --git a/js/libs/fluidbook/fluidbook.splash.js b/js/libs/fluidbook/fluidbook.splash.js index 41618a80..9004a806 100644 --- a/js/libs/fluidbook/fluidbook.splash.js +++ b/js/libs/fluidbook/fluidbook.splash.js @@ -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 diff --git a/style/flip3d.less b/style/flip3d.less index a6059059..c51ed011 100644 --- a/style/flip3d.less +++ b/style/flip3d.less @@ -1,4 +1,3 @@ - /* 3D Flip */ #flip3dcontainer { @@ -15,6 +14,10 @@ position: relative; left: 0; } + + .perftest & { + visibility: hidden !important; + } } .ios #pages {