From 8bd3a0e4c8fb0f3d94f112cca2c0b73bb331abbc Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Tue, 26 Mar 2024 19:18:45 +0100 Subject: [PATCH] wip #6834 @0.25 --- js/libs/fluidbook/fluidbook.loader.js | 128 +++++++++++++------------- 1 file changed, 65 insertions(+), 63 deletions(-) diff --git a/js/libs/fluidbook/fluidbook.loader.js b/js/libs/fluidbook/fluidbook.loader.js index d72344ce..64c1cbec 100644 --- a/js/libs/fluidbook/fluidbook.loader.js +++ b/js/libs/fluidbook/fluidbook.loader.js @@ -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 = $(''); - $("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 = $(''); + $("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(); -- 2.39.5