]> _ Git - fluidbook-html5.git/commitdiff
wip #6781 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 8 Mar 2024 14:33:35 +0000 (15:33 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 8 Mar 2024 14:33:35 +0000 (15:33 +0100)
js/libs/fluidbook/fluidbook.loader.js

index 47bc12b25b08d0fcaf185eb3552e650061ca9687..18d7b7ae95b3a2ad9a9688695aafaef7c6426b82 100644 (file)
@@ -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);