]> _ Git - fluidbook-html5.git/commitdiff
wip #6834 @0.25
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 26 Mar 2024 18:18:45 +0000 (19:18 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 26 Mar 2024 18:18:45 +0000 (19:18 +0100)
js/libs/fluidbook/fluidbook.loader.js

index d72344ce546a37cf078577da0cf934da7bb3daae..64c1cbec7c87b5de3f2a690f34c90d6407e31fd3 100644 (file)
@@ -686,69 +686,6 @@ FluidbookLoader.prototype = {
         this._preloadContentLinkTextures(page, this.fluidbook.settings.clinks[page], this.fluidbook.settings.links[page], enter, function (textures, clinks) {
             if ($this.fluidbook.pagetransitions.flip3d !== false) {
 
-                let drawTexts = function () {
-                    // Draw the texts if necessary
-                    if ($this.getVersionToLoad(page) === 'textasvector' || $this.getVersionToLoad(page) === 'vector') {
-                        if ($this.fluidbook.support.pdftocanvas) {
-                            $this.renderPDFPageToCanvas(page, ctx, dw, dh, function () {
-                                afterTexts();
-                            });
-                        } else {
-                            try {
-                                let img = $this.texts[page];
-                                if (img !== undefined && img !== null) {
-                                    img = img.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, dw + 2, dh);
-                                }
-                            } catch (e) {
-                                console.warn(e);
-                            }
-                            afterTexts();
-                        }
-                    } else {
-                        afterTexts();
-                    }
-                };
-
-                let dh = screen.height * window.devicePixelRatio * 1.1;
-                let dw = $this.fluidbook.settings.width * (dh / $this.fluidbook.settings.height);
-                let canvas = $('<canvas class="pscanvas" id="pscanvas_' + page + '" width="' + dw + '" height="' + dh + '" aria-hidden="true"></canvas>');
-                $("body").append(canvas);
-                let c = canvas.get(0);
-                let ctx = c.getContext("2d");
-
-                let wr = dw / $this.fluidbook.settings.width;
-                let hr = dh / $this.fluidbook.settings.height;
-
-                // Draw background
-                ctx.fillStyle = "#FFFFFF";
-                ctx.fillRect(0, 0, dw, dh);
-                if ($this.backgrounds[page] !== undefined && $this.backgrounds[page] !== null) {
-                    let img = $this.backgrounds[page].get(0);
-                    if (img.complete) {
-                        ctx.drawImage(img, 0, 0, dw * 1.002, dh);
-                        drawTexts();
-                    } else {
-                        let interval = setInterval(function () {
-                            if (img.complete) {
-                                clearInterval(interval);
-                                ctx.drawImage(img, 0, 0, dw * 1.002, dh);
-                                drawTexts();
-                            }
-                        });
-                    }
-                } else {
-                    drawTexts();
-                }
-
-
-
                 let afterTexts = function () {
                     // Draw content links
                     if (clinks !== '') {
@@ -873,6 +810,71 @@ FluidbookLoader.prototype = {
                     }
                 };
 
+                let drawTexts = function () {
+                    // Draw the texts if necessary
+                    if ($this.getVersionToLoad(page) === 'textasvector' || $this.getVersionToLoad(page) === 'vector') {
+                        if ($this.fluidbook.support.pdftocanvas) {
+                            $this.renderPDFPageToCanvas(page, ctx, dw, dh, function () {
+                                afterTexts();
+                            });
+                        } else {
+                            try {
+                                let img = $this.texts[page];
+                                if (img !== undefined && img !== null) {
+                                    img = img.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, dw + 2, dh);
+                                }
+                            } catch (e) {
+                                console.warn(e);
+                            }
+                            afterTexts();
+                        }
+                    } else {
+                        afterTexts();
+                    }
+                };
+
+                let dh = screen.height * window.devicePixelRatio * 1.1;
+                let dw = $this.fluidbook.settings.width * (dh / $this.fluidbook.settings.height);
+                let canvas = $('<canvas class="pscanvas" id="pscanvas_' + page + '" width="' + dw + '" height="' + dh + '" aria-hidden="true"></canvas>');
+                $("body").append(canvas);
+                let c = canvas.get(0);
+                let ctx = c.getContext("2d");
+
+                let wr = dw / $this.fluidbook.settings.width;
+                let hr = dh / $this.fluidbook.settings.height;
+
+                // Draw background
+                ctx.fillStyle = "#FFFFFF";
+                ctx.fillRect(0, 0, dw, dh);
+                if ($this.backgrounds[page] !== undefined && $this.backgrounds[page] !== null) {
+                    let img = $this.backgrounds[page].get(0);
+                    if (img.complete) {
+                        ctx.drawImage(img, 0, 0, dw * 1.002, dh);
+                        drawTexts();
+                    } else {
+                        let interval = setInterval(function () {
+                            if (img.complete) {
+                                clearInterval(interval);
+                                ctx.drawImage(img, 0, 0, dw * 1.002, dh);
+                                drawTexts();
+                            }
+                        });
+                    }
+                } else {
+                    drawTexts();
+                }
+
+
+
+
+
 
             } else {
                 callback();