]> _ Git - fluidbook-html5.git/commitdiff
wait #4552 @4
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 25 Jun 2021 16:55:31 +0000 (18:55 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 25 Jun 2021 16:55:31 +0000 (18:55 +0200)
js/libs/cube/util.js
js/libs/fluidbook/fluidbook.loader.js

index d74353b5d313172be74b1015a98b52faa76ee967..29bdc18175a0cd018835ebb8e91687d316a3395a 100644 (file)
@@ -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;
index d7fd15ada352ea5833fed7b7eb8fc778dfd63e12..1b9af86f3a5c0a71800bd987f067a92b2045718f 100644 (file)
@@ -511,7 +511,7 @@ FluidbookLoader.prototype = {
         });
 
         if (cl === '') {
-            callback(textures);
+            callback(textures, cl);
             return;
         }
         $("body").append('<div class="texture_clinks" data-page="' + page + '">' + cl + '</div>');
@@ -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);
                         }