]> _ Git - fluidbook-html5.git/commitdiff
wait #6532 @0.25
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 30 Nov 2023 09:43:59 +0000 (10:43 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 30 Nov 2023 09:43:59 +0000 (10:43 +0100)
js/libs/fluidbook/fluidbook.links.js
js/libs/fluidbook/fluidbook.loader.js

index 1beb8c4479b28f362087bc833fa33c21f2ad4005..766efeb48d13ef85f1b0eb247143df6996b451b3 100644 (file)
@@ -768,7 +768,6 @@ FluidbookLinks.prototype = {
     },
 
     animateContentLink: function (link, autostart, force, delay) {
-
         if (force === undefined) {
             force = false;
         }
index 83c267593f2642f3457588e26f9838707b0a0896..cd352a01cf34d10caef6d8838040ddc5af84ee45 100644 (file)
@@ -145,7 +145,6 @@ FluidbookLoader.prototype = {
             return;
         }
 
-
         var $this = this;
         var $pages = pages.slice(0);
         if ($pages.length == 0) {
@@ -226,19 +225,17 @@ FluidbookLoader.prototype = {
         var $this = this;
         var $_callback;
 
-        if (this.fluidbook.pagetransitions.flip3d !== false) {
-            $_callback = function () {
-                $this.loadTexture(page, function () {
-                    if ($this.needSeparateTextures(page)) {
-                        $this.loadTexture(page, callback, false);
-                    } else {
-                        callback();
-                    }
-                }, true);
-            };
-        } else {
-            $_callback = callback;
-        }
+
+        $_callback = function () {
+            $this.loadTexture(page, function () {
+                if ($this.needSeparateTextures(page)) {
+                    $this.loadTexture(page, callback, false);
+                } else {
+                    callback();
+                }
+            }, true);
+        };
+
 
         var $__callback = function () {
             if ($this.getVersionToLoad(page) === 'textasvector' || $this.getVersionToLoad(page) === 'vector') {
@@ -679,120 +676,126 @@ FluidbookLoader.prototype = {
         }
         var $this = this;
 
-        this._preloadContentLinkTextures(page, this.fluidbook.settings.clinks[page], this.fluidbook.settings.links[page], enter, function (textures, clinks) {
-            var d = 1024;
-            var c = document.getElementById("pscanvas");
-            c.width = d;
-            c.height = d;
-            var ctx = c.getContext("2d");
-            ctx.clearRect(0, 0, d, d);
-
-            var wr = d / $this.fluidbook.settings.width;
-            var hr = d / $this.fluidbook.settings.height;
-
-            // Draw background
-            if ($this.backgrounds[page] !== undefined && $this.backgrounds[page] !== null) {
-                ctx.drawImage($this.backgrounds[page].get(0), 0, 0, d * 1.002, d);
-            } else {
-                ctx.fillStyle = "#FFFFFF";
-                ctx.fillRect(0, 0, d, d);
-            }
-            // Draw the texts if necessary
-            if ($this.getVersionToLoad(page) === 'textasvector' || $this.getVersionToLoad(page) === 'vector') {
-                try {
-                    var img = $this.texts[page].get(0);
-                    if (img.width === 0) {
-                        $this.deletePage(page);
-                        $this._preloadPage(page, callback);
-                        console.warn('failed to load page for drawing texture ', page);
-                        return;
-                    }
-                    ctx.drawImage(img, -1, 0, d + 2, d);
-                } catch (e) {
-                    console.warn(e);
-                }
-            }
-
-            // 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]'))) {
-                        return;
-                    }
-                    var left = parseFloat($(this).css('left')) * wr;
-                    var top = parseFloat($(this).css('top')) * hr;
-                    var width = parseFloat($(this).css('width')) * wr;
-                    var height = parseFloat($(this).css('height')) * hr;
-
-                    var blendmode = $(this).data('blendmode');
-
-                    if (blendmode === 'normal') {
-                        ctx.globalCompositeOperation = 'source-over';
+        this._preloadContentLinkTextures(page, this.fluidbook.settings.clinks[page], this.fluidbook.settings.links[page], enter,
+            function (textures, clinks) {
+                if ($this.fluidbook.pagetransitions.flip3d !== false) {
+                    var d = 1024;
+                    var c = document.getElementById("pscanvas");
+                    c.width = d;
+                    c.height = d;
+                    var ctx = c.getContext("2d");
+                    ctx.clearRect(0, 0, d, d);
+
+                    var wr = d / $this.fluidbook.settings.width;
+                    var hr = d / $this.fluidbook.settings.height;
+
+                    // Draw background
+                    if ($this.backgrounds[page] !== undefined && $this.backgrounds[page] !== null) {
+                        ctx.drawImage($this.backgrounds[page].get(0), 0, 0, d * 1.002, d);
                     } else {
+                        ctx.fillStyle = "#FFFFFF";
+                        ctx.fillRect(0, 0, d, d);
+                    }
+                    // Draw the texts if necessary
+                    if ($this.getVersionToLoad(page) === 'textasvector' || $this.getVersionToLoad(page) === 'vector') {
                         try {
-                            ctx.globalCompositeOperation = blendmode;
+                            var img = $this.texts[page].get(0);
+                            if (img.width === 0) {
+                                $this.deletePage(page);
+                                $this._preloadPage(page, callback);
+                                console.warn('failed to load page for drawing texture ', page);
+                                return;
+                            }
+                            ctx.drawImage(img, -1, 0, d + 2, d);
                         } catch (e) {
-                            ctx.globalCompositeOperation = 'source-over';
+                            console.warn(e);
                         }
                     }
 
-                    if ($(this).is('[data-layer="bothsvg"]')) {
-                        ctx.fillStyle = '#ffffff';
-                        ctx.fillRect(left, top, width, height);
-                    }
+                    // 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]'))) {
+                                return;
+                            }
+                            var left = parseFloat($(this).css('left')) * wr;
+                            var top = parseFloat($(this).css('top')) * hr;
+                            var width = parseFloat($(this).css('width')) * wr;
+                            var height = parseFloat($(this).css('height')) * hr;
+
+                            var blendmode = $(this).data('blendmode');
+
+                            if (blendmode === 'normal') {
+                                ctx.globalCompositeOperation = 'source-over';
+                            } else {
+                                try {
+                                    ctx.globalCompositeOperation = blendmode;
+                                } catch (e) {
+                                    ctx.globalCompositeOperation = 'source-over';
+                                }
+                            }
 
-                    if ($(this).is('[data-color]')) {
-                        ctx.fillStyle = $(this).attr('data-color');
-                        ctx.fillRect(left, top, width, height);
-                    } else if ($(this).is('[data-image]')) {
-                        var i = $(this).data('id');
-                        if (textures[i] !== undefined && textures[i] !== null) {
-                            try {
-                                ctx.drawImage(textures[i].get(0), left, top, width, height);
-                            } catch (e) {
-                                console.warn(textures[i]);
+                            if ($(this).is('[data-layer="bothsvg"]')) {
+                                ctx.fillStyle = '#ffffff';
+                                ctx.fillRect(left, top, width, height);
                             }
-                        }
+
+                            if ($(this).is('[data-color]')) {
+                                ctx.fillStyle = $(this).attr('data-color');
+                                ctx.fillRect(left, top, width, height);
+                            } else if ($(this).is('[data-image]')) {
+                                var i = $(this).data('id');
+                                if (textures[i] !== undefined && textures[i] !== null) {
+                                    try {
+                                        ctx.drawImage(textures[i].get(0), left, top, width, height);
+                                    } catch (e) {
+                                        console.warn(textures[i]);
+                                    }
+                                }
+                            }
+                        });
+                        $('.texture_clinks[data-page="' + page + '"]').remove();
                     }
-                });
-                $('.texture_clinks[data-page="' + page + '"]').remove();
-            }
 
-            // Draw the shadow if necessary
-            if ($this.fluidbook.settings.shadeAlpha > 0) {
-                var sw = d * .25;
-                var s, x;
-                if (page % 2 === 0) {
-                    // Left
-                    s = $this.shadeLeft;
-                    x = 1024 - sw;
-                } else {
-                    // Right
-                    s = $this.shadeRight;
-                    x = 0;
-                }
-                ctx.globalAlpha = 2 * $this.fluidbook.settings.shadeAlpha / 100;
-                ctx.drawImage(s.get(0), x, 0, sw, d);
-                ctx.globalAlpha = 1;
-            }
+                    // Draw the shadow if necessary
+                    if ($this.fluidbook.settings.shadeAlpha > 0) {
+                        var sw = d * .25;
+                        var s, x;
+                        if (page % 2 === 0) {
+                            // Left
+                            s = $this.shadeLeft;
+                            x = 1024 - sw;
+                        } else {
+                            // Right
+                            s = $this.shadeRight;
+                            x = 0;
+                        }
+                        ctx.globalAlpha = 2 * $this.fluidbook.settings.shadeAlpha / 100;
+                        ctx.drawImage(s.get(0), x, 0, sw, d);
+                        ctx.globalAlpha = 1;
+                    }
 
-            try {
-                let dataurl = c.toDataURL("image/png");
-                var i = new Image();
-                i.onload = function () {
-                    if (enter) {
-                        $this.textures[page] = i;
-                    } else {
-                        $this.leaveTextures[page] = i;
+                    try {
+                        let dataurl = c.toDataURL("image/png");
+                        var i = new Image();
+                        i.onload = function () {
+                            if (enter) {
+                                $this.textures[page] = i;
+                            } else {
+                                $this.leaveTextures[page] = i;
+                            }
+                            callback();
+                        }
+                        i.src = dataurl;
+                    } catch (e) {
+                        console.warn(e);
+                        callback();
                     }
+                } else {
                     callback();
                 }
-                i.src = dataurl;
-            } catch (e) {
-                console.warn(e);
-                callback();
             }
-        });
+        );
     },
 
     getURL(url) {