]> _ Git - fluidbook-html5.git/commitdiff
wait #7087 @2
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 18 Sep 2024 17:07:04 +0000 (19:07 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 18 Sep 2024 17:07:04 +0000 (19:07 +0200)
js/libs/fluidbook/fluidbook.loader.js

index 4f494b92f26dd005273f17e1bd881b20171c7e22..e375c295dbe20a886f366040e40b5faf5ec16719 100644 (file)
@@ -685,7 +685,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 afterTexts = function () {
                     // Draw content links
                     if (clinks !== '') {
@@ -698,6 +697,19 @@ FluidbookLoader.prototype = {
                             }
 
 
+                            if ($(this).is('[data-polygon]')) {
+                                let p = $(this).data('polygon');
+                                let clip = new Path2D();
+                                clip.moveTo(p[0].x * cwr, p[0].y * chr);
+                                for (let i = 1; i < p.length; i++) {
+                                    clip.lineTo(p[i].x * cwr, p[i].y * chr);
+                                }
+                                clip.lineTo(p[0].x * cwr, p[0].y * chr);
+                                ctx.save();
+                                ctx.clip(clip);
+                            }
+
+
                             let texture;
 
                             let scale = 1;
@@ -769,6 +781,9 @@ FluidbookLoader.prototype = {
                                     console.warn(texture);
                                 }
                             }
+                            if ($(this).is('[data-polygon]')) {
+                                ctx.restore();
+                            }
                         });
                         $('.texture_clinks[data-page="' + page + '"]').remove();
                     }
@@ -850,6 +865,9 @@ FluidbookLoader.prototype = {
                 let wr = dw / $this.fluidbook.settings.width;
                 let hr = dh / $this.fluidbook.settings.height;
 
+                let cwr = wr * this.fluidbook.settings.cssScale;
+                let chr = hr * this.fluidbook.settings.cssScale;
+
                 // Draw background
                 ctx.fillStyle = "#FFFFFF";
                 ctx.fillRect(0, 0, dw, dh);