From: Vincent Vanwaelscappel Date: Fri, 25 Jun 2021 16:55:31 +0000 (+0200) Subject: wait #4552 @4 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=75f957c7071e6e7a9fa9a2322ea2fd95ba72edfd;p=fluidbook-html5.git wait #4552 @4 --- diff --git a/js/libs/cube/util.js b/js/libs/cube/util.js index d74353b5..29bdc181 100644 --- a/js/libs/cube/util.js +++ b/js/libs/cube/util.js @@ -114,9 +114,12 @@ function guid() { s4() + '-' + s4() + s4() + s4(); } -function loadImage(src, callback) { +function loadImage(src, callback,id) { var img = new Image(); var loaded = false; + if(id!==undefined) { + img.id = id; + } $(img).on('load', function () { if (loaded) { return; diff --git a/js/libs/fluidbook/fluidbook.loader.js b/js/libs/fluidbook/fluidbook.loader.js index d7fd15ad..1b9af86f 100644 --- a/js/libs/fluidbook/fluidbook.loader.js +++ b/js/libs/fluidbook/fluidbook.loader.js @@ -511,7 +511,7 @@ FluidbookLoader.prototype = { }); if (cl === '') { - callback(textures); + callback(textures, cl); return; } $("body").append(''); @@ -521,20 +521,21 @@ FluidbookLoader.prototype = { var cb = function () { loaded++; if (loaded === nb) { - callback(textures); + callback(textures, cl); } }; + $('.texture_clinks[data-page="' + page + '"] .contentLink[data-image]').each(function () { if ((enter && $(this).is('[data-animation-hide]')) || (!enter && $(this).is('[data-animation-hide-on-leave]'))) { return; } nb++; - var i = $(this).data('image'); - var url = i.replace(/^\.\./, 'data'); - textures[i] = loadImage(url, cb); + var i = $(this).data('id'); + var url = $(this).data('image').replace(/^\.\./, 'data') + '?j=' + (new Date()).getTime(); + textures[i] = loadImage(url, cb, 'i_' + i); }); if (nb === 0) { - callback(textures); + callback(textures, cl); return; } }, @@ -548,9 +549,8 @@ FluidbookLoader.prototype = { return; } var $this = this; - var clinks = this.handleExtension(this.fluidbook.settings.clinks[page]); - this._preloadContentLinkTextures(page, clinks, enter, function (textures) { + this._preloadContentLinkTextures(page, this.fluidbook.settings.clinks[page], enter, function (textures, clinks) { var d = 1024; var c = document.getElementById("pscanvas"); c.width = d; @@ -583,7 +583,6 @@ FluidbookLoader.prototype = { } // Draw content links - if (clinks !== '') { $('.texture_clinks[data-page="' + page + '"] .contentLink').each(function () { if ((enter && $(this).is('[data-animation-hide]')) || (!enter && $(this).is('[data-animation-hide-on-leave]'))) { @@ -597,7 +596,8 @@ FluidbookLoader.prototype = { ctx.fillStyle = $(this).attr('data-color'); ctx.fillRect(left, top, width, height); } else if ($(this).is('[data-image]')) { - var i = $(this).data('image'); + var i = $(this).data('id'); + console.log(i, textures[i], left, top, width, height); if (textures[i] !== undefined && textures[i] !== null) { ctx.drawImage(textures[i], left, top, width, height); }