From 401ab0d938c765707687698e4908093931770fe7 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Mon, 10 May 2021 08:15:44 +0200 Subject: [PATCH] wip #4448 @4 --- js/libs/fluidbook/fluidbook.3dflip.js | 11 +++++--- js/libs/fluidbook/fluidbook.loader.js | 40 +++++++++++++++++++-------- style/fluidbook.less | 2 +- 3 files changed, 37 insertions(+), 16 deletions(-) diff --git a/js/libs/fluidbook/fluidbook.3dflip.js b/js/libs/fluidbook/fluidbook.3dflip.js index eaf67edd..31c54ae1 100644 --- a/js/libs/fluidbook/fluidbook.3dflip.js +++ b/js/libs/fluidbook/fluidbook.3dflip.js @@ -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) { diff --git a/js/libs/fluidbook/fluidbook.loader.js b/js/libs/fluidbook/fluidbook.loader.js index c6445e02..cfb26b0e 100644 --- a/js/libs/fluidbook/fluidbook.loader.js +++ b/js/libs/fluidbook/fluidbook.loader.js @@ -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]); } }, diff --git a/style/fluidbook.less b/style/fluidbook.less index ca612119..5f4fb5c4 100644 --- a/style/fluidbook.less +++ b/style/fluidbook.less @@ -3051,7 +3051,7 @@ body > input { display: none; } -.textures_clinks { +.texture_clinks { visibility: hidden; } -- 2.39.5