]> _ Git - fluidbook-html5.git/commitdiff
wait #4713 @2.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 28 Sep 2021 11:56:44 +0000 (13:56 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 28 Sep 2021 11:56:44 +0000 (13:56 +0200)
js/libs/fluidbook/fluidbook.loader.js
style/fluidbook.less

index 6aab0a324ab8ad0212f8f829c65cf895675851ee..12c6662342535a5142ee8e14f1858f7d69f017a5 100644 (file)
@@ -694,9 +694,8 @@ FluidbookLoader.prototype = {
 
         var upscale = this.fluidbook.settings.svgToCanvasUpscale !== undefined ? this.fluidbook.settings.svgToCanvasUpscale : 1;
 
-        var z = this.fluidbook.resize.bookScale * upscale;
-        var mz = this.fluidbook.resize.bookScale * this.fluidbook.zoom.max * upscale;
-
+        var z = upscale;
+        var mz = this.fluidbook.zoom.max * upscale * 1.1;
 
         $('canvas[data-page]').each(function () {
             if ($this.fluidbook.zoom.zoom === 1 && $(this).hasClass('z')) {
@@ -704,28 +703,37 @@ FluidbookLoader.prototype = {
             }
 
             var page = $(this).data('page');
-            var dim = $this.getPageDimensions(page);
+            var c = $(this).closest('.texts');
+            var tw = $(c).width();
+            var th = $(c).height();
+
 
-            var w = dim.width * z;
-            var h = dim.height * z;
-            var wz = dim.width * mz;
-            var hz = dim.height * mz;
+            var w = tw * z;
+            var h = th * z;
+            var wz = tw * mz;
+            var hz = th * mz;
 
             var canvas = $(this).get(0);
 
 
-            if ($(this).data('bookScale') === z) {
+            if ($(this).data('bookScale') === w) {
                 return;
             }
 
+            var cz = $(this).hasClass('z') ? mz : z;
             var cw = $(this).hasClass('z') ? wz : w;
             var ch = $(this).hasClass('z') ? hz : h;
 
-            canvas.width = cw;
-            canvas.height = ch;
+            canvas.width = cw + 30;
+            canvas.height = ch + 30;
+
+            if (cz === 1) {
+                $(canvas).css('transform', null);
+            } else {
+                $(canvas).css('transform', 'scale(' + (1 / cz) + ')');
+            }
 
             var ctx = canvas.getContext("2d");
-            ctx.clearRect(0, 0, cw, ch);
 
             var img = $this.texts[page].get(0);
             if (img.width === 0) {
@@ -733,8 +741,8 @@ FluidbookLoader.prototype = {
                 $this._preloadPage(page, callback);
                 return;
             }
-            ctx.drawImage(img, 0, 0, cw, ch);
-            $(this).data('bookScale', z);
+            ctx.drawImage(img, 0, 0, img.width * 0.998, img.height * 0.998, 0, 0, cw, ch);
+            $(this).data('bookScale', w);
         });
     },
 
index 016c4aec721afcd7cd865e7865996d50cde05677..d74706220bbf0b19a0f5cc133f7e4e667e53584b 100644 (file)
@@ -370,7 +370,8 @@ body, html {
   background-color: @pages-background;
 
   img {
-    width: ~"calc(100% + 1px)";
+    //width: ~"calc(100% + 1px)";
+    width: 100%;
     height: 100%;
   }
 }
@@ -383,7 +384,7 @@ body, html {
   width: 100%;
   height: 100%;
 
-  img, object, canvas {
+  img, object {
     position: absolute;
     top: 0px;
     left: 0px;
@@ -392,6 +393,12 @@ body, html {
   }
 
   canvas {
+    position: absolute;
+    top: 0px;
+    left: 0px;
+    transform-origin: 0 0;
+
+
     &.p {
       display: block;
 
@@ -402,7 +409,6 @@ body, html {
 
     &.z {
       display: none;
-
       .zoomed & {
         display: block;
       }
@@ -420,7 +426,7 @@ body, html {
   max-height: 100%;
 }
 
-.portrait .page{
+.portrait .page {
   width: 100%;
   max-width: 100%;
 }