From: Vincent Vanwaelscappel Date: Fri, 8 Mar 2024 14:33:35 +0000 (+0100) Subject: wip #6781 @1 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=9fadc12028b331e5b990b31f3f4daf29867cddde;p=fluidbook-html5.git wip #6781 @1 --- diff --git a/js/libs/fluidbook/fluidbook.loader.js b/js/libs/fluidbook/fluidbook.loader.js index 47bc12b2..18d7b7ae 100644 --- a/js/libs/fluidbook/fluidbook.loader.js +++ b/js/libs/fluidbook/fluidbook.loader.js @@ -698,14 +698,17 @@ FluidbookLoader.prototype = { // 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; + var 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, d + 2, d); } - ctx.drawImage(img, -1, 0, d + 2, d); } catch (e) { console.warn(e); } @@ -918,7 +921,6 @@ FluidbookLoader.prototype = { var page = $(this).data('page'); - var c = $(this).closest('.texts'); var tw = $(c).width(); var th = $(c).height(); @@ -968,13 +970,19 @@ FluidbookLoader.prototype = { console.info($this.texts[page]); } } else { - var img = $this.texts[page].get(0); - if (img.width === 0) { - $this.deletePage(page); - $this._preloadPage(page, callback); - return; + var img = $this.texts[page]; + if (img !== undefined && img !== null) { + img = img.get(0); + if (img.width === 0) { + $this.deletePage(page); + $this._preloadPage(page, function () { + + }); + return; + } + ctx.drawImage(img, 0, 0, img.width - 2, img.height - 2, 0, 0, cw, ch); } - ctx.drawImage(img, 0, 0, img.width - 2, img.height - 2, 0, 0, cw, ch); + } $(this).data('w', cw).data('h', ch);