]> _ Git - fluidbook-html5.git/commitdiff
wip #5158 @2
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 1 Apr 2022 15:52:28 +0000 (17:52 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 1 Apr 2022 15:52:28 +0000 (17:52 +0200)
js/libs/fluidbook/fluidbook.desktop.js
js/libs/fluidbook/fluidbook.nav.js
js/libs/fluidbook/fluidbook.zoom.js

index 178dac75a31dcff47d85affbc7b1059da48747a1..77bb4c25d6387839fe10d3de8fc8b2e9e41e476d 100644 (file)
@@ -16,7 +16,12 @@ FluidbookDesktop.prototype = {
             }
         });
         $(document).on('click', '#links', function (e) {
-            if ($this.fluidbook.zoom.enabled && $this.fluidbook.input.isUsingMouse() && !$this.fluidbook.hasDraggableOnPage()) {
+            if (
+                $this.fluidbook.settings.clickZoom &&
+                $this.fluidbook.zoom.enabled &&
+                $this.fluidbook.input.isUsingMouse() &&
+                !$this.fluidbook.hasDraggableOnPage()
+            ) {
                 $this.clickZoom(e);
                 return false;
             }
@@ -27,7 +32,7 @@ FluidbookDesktop.prototype = {
 
 
         $(document).on('mousemove', 'body', function (e) {
-            if ($this.fluidbook.zoom.enabled) {
+            if ($this.fluidbook.zoom.enabled && $this.fluidbook.settings.zoomMouseMoveMode === 'move') {
                 $this.moveZoom(e);
             }
         });
@@ -56,7 +61,7 @@ FluidbookDesktop.prototype = {
         } else if (way == -1) {
             newScale = 1;
         }
-        this.moveZoom(e, true)
+        this.moveZoom(e, true);
         this.fluidbook.zoom.setZoom(newScale);
         return false;
     },
index b2e786b8fd1cb569b206b23ca88d4e6fdccac442..4203ab68ffe51bbfb284d623e24e17394a64a3bc 100644 (file)
@@ -464,6 +464,7 @@ FluidbookNav.prototype = {
                 // __('zoom out')
                 link = this.addLink(navType, 'nav-zoomin', '#', 'zoomin', 'zoom in', 'zoom in');
                 link = this.addLink(navType, 'nav-zoomout', '#', 'zoomout', 'zoom out', 'zoom out');
+
             } else if (icon === 'fullscreen' && this.fluidbook.settings.fullscreen && this.fluidbook.support.fullscreen && !this.fluidbook.settings.phonegap) {
                 // __('switch between fullscreen and normal')
                 link = this.addLink(navType, 'nav-' + icon, '#', icon, 'full screen', 'switch between fullscreen and normal', 'F11');
@@ -731,17 +732,6 @@ FluidbookNav.prototype = {
             }
         });
 
-        // Zoom In icon
-        $(document).on(this.fluidbook.input.clickEvent, '.icon-zoomin', function (e) {
-            $this.fluidbook.desktop.clickZoom(e, 'in');
-            return false;
-        });
-
-        // Zoom Out icon
-        $(document).on(this.fluidbook.input.clickEvent, '.icon-zoomout', function (e) {
-            $this.fluidbook.desktop.clickZoom(e, 'out');
-            return false;
-        });
 
         if (this.fluidbook.support.fullscreen) {
             this.initFullScreen();
index 341841f0e2693e7cb720b8918eb4375bea2c5366..2eaad2b491a10d77915e5482b6fb06549bd63a6d 100644 (file)
@@ -2,6 +2,7 @@ function FluidbookZoom(fluidbook) {
     this.fluidbook = fluidbook;
     this.zoom = 0;
     this.originpct = [0.5, 0.5];
+    this.zoomStep = 0.7;
     this.originpx = ['0px', '0px'];
     this.initial = this.fluidbook.settings.zoom / 100;
     this.max = this.fluidbook.settings.zoomw / 100;
@@ -14,16 +15,35 @@ function FluidbookZoom(fluidbook) {
 
 FluidbookZoom.prototype = {
     init: function () {
-        if (this.fluidbook.mobilefirst.enabled) {
+        if (this.fluidbook.mobilefirst.enabled || (this.fluidbook.settings.zoom <= 100 && this.fluidbook.settings.zoomw <= 100)) {
             this.disable();
             return;
         }
+        if (!this.fluidbook.settings.clickZoom) {
+            this.disableZoomCursor();
+        }
 
         var $this = this;
         this.setTransition(true);
 
         this.initMouseWheel();
 
+        // Zoom icon
+        $(document).on(this.fluidbook.input.clickEvent, '.icon-zoomin', function (e) {
+            if ($this.fluidbook.settings.zoomMouseMoveMode !== 'dragndrop') {
+                $this.fluidbook.desktop.moveZoom(e, true);
+            } else {
+                $this.fluidbook.zoom.setOriginPct(0.5, 0.5, true);
+            }
+            $this.fluidbook.zoom.zoomInFromMenu();
+
+            return false;
+        });
+        $(document).on(this.fluidbook.input.clickEvent, '.icon-zoomout', function (e) {
+            $this.fluidbook.zoom.zoomOutFromMenu();
+            return false;
+        });
+
         $(this.fluidbook).on('fluidbook.zoom.out.end', function () {
             $("#z").addClass('nozoom');
         });
@@ -74,10 +94,10 @@ FluidbookZoom.prototype = {
     wheelZoom: function (delta) {
         var dir;
         if (delta > 0) {
-            delta = 0.7;
+            delta = this.zoomStep;
             dir = 1;
         } else {
-            delta = -0.7;
+            delta = -1 * this.zoomStep;
             dir = -1;
         }
         this.setZoom(this.zoom + delta, dir);
@@ -121,7 +141,11 @@ FluidbookZoom.prototype = {
     },
 
     disable: function () {
+        this.disableZoomCursor();
         this.enabled = false;
+    },
+
+    disableZoomCursor: function () {
         $('body').addClass('zoom-disabled');
     },
 
@@ -138,6 +162,7 @@ FluidbookZoom.prototype = {
 
 
     setZoom: function (zoom, direction, end) {
+        console.log('set zoom ', zoom);
         var origZoom = this.zoom;
 
         if (end === undefined) {
@@ -180,6 +205,22 @@ FluidbookZoom.prototype = {
         }
     },
 
+    zoomInFromMenu: function () {
+        if (this.zoom === 1) {
+            this.setZoom(this.fluidbook.settings.zoom / 100);
+        } else {
+            this.setZoom(this.zoom + this.zoomStep);
+        }
+    },
+
+    zoomOutFromMenu: function () {
+        var z = this.zoom - this.zoomStep;
+        if (z < 1 + this.zoomStep) {
+            z = 1;
+        }
+        this.setZoom(z);
+    },
+
     setTransition: function (transition) {
         if (transition == undefined) {
             transition = true;
@@ -281,7 +322,12 @@ FluidbookZoom.prototype = {
         // When the search results nav is active, don't reveal interface elements when zooming out...
         if (!this.fluidbook.search.resultsNavActive()) {
 
-            var hiddenElements = $("header,footer,#interface,#links a.bookmark");
+            var selector = 'footer,#interface,#links a.bookmark';
+            if (this.fluidbook.settings.hideHeaderOnZoom) {
+                selector += ',header';
+            }
+            var hiddenElements = $(selector);
+
 
             if (this.zoom !== 1) {
                 if (this.fluidbook.help !== undefined) {
@@ -318,7 +364,7 @@ FluidbookZoom.prototype = {
         }
         try {
             this.fluidbook.loader.renderTextsCanvas();
-        }catch (e){
+        } catch (e) {
 
         }