]> _ Git - fluidbook-html5.git/commitdiff
wip #4314 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 2 Mar 2021 09:13:41 +0000 (10:13 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 2 Mar 2021 09:13:41 +0000 (10:13 +0100)
js/libs/fluidbook/fluidbook.desktop.js
js/libs/fluidbook/fluidbook.help.js
js/libs/fluidbook/fluidbook.zoom.js

index d6e51c2ab68247981f3e1a0f15f06a4325aa9ad0..0d253b62ee508e2da52a54831f4f089dea604ee5 100644 (file)
@@ -26,11 +26,6 @@ FluidbookDesktop.prototype = {
         })
 
 
-        $(document).on('mousewheel', function (e) {
-            if ($this.fluidbook.zoom.enabled) {
-                $this.wheelZoom(e.deltaY);
-            }
-        });
         $(document).on('mousemove', 'body', function (e) {
             if ($this.fluidbook.zoom.enabled) {
                 $this.moveZoom(e);
@@ -65,12 +60,6 @@ FluidbookDesktop.prototype = {
         this.fluidbook.zoom.setZoom(newScale);
         return false;
     },
-    wheelZoom: function (delta) {
-        // Disable scroll zoom when either a view or the menu is open...
-        if ($("body").is('.view, .menu-open')) {
-            return;
-        }
-        this.fluidbook.zoom.setZoom(this.fluidbook.zoom.zoom + delta / 3, delta > 0 ? 1 : -1);
-    },
+
 
 };
\ No newline at end of file
index 4d8956af80b32d58e08fae8a9bd350c99819a22a..2e01fa9dc17e7e774d04bcf128c1a25d19ce3151 100644 (file)
@@ -78,7 +78,12 @@ FluidbookHelp.prototype = {
         if (this.fluidbook.mobilefirst.enabled) {
             text = this.fluidbook.l10n.__('scroll down to read the page content');
         } else {
-            text = this.fluidbook.l10n.__('click once to zoom in, click again to zoom out') + '<br />' + this.fluidbook.l10n.__('roll the mouse wheel to zoom in/out');
+            text = this.fluidbook.l10n.__('click once to zoom in, click again to zoom out');
+            if (this.fluidbook.settings.zoomWheel === 'wheel') {
+                text += '<br />' + this.fluidbook.l10n.__('roll the mouse wheel to zoom in/out');
+            } else if (this.fluidbook.settings.zoomWheel === 'ctrlwheel') {
+                text += '<br />' + this.fluidbook.l10n.__('use Ctrl + scroll to zoom in/out');
+            }
         }
 
         help += '<div class="illustration mouse">' + getSpriteIcon('help-mouse', {
index 960b9e95c09ed95d1eb6dba65a873f6665c5dd3a..e0bd67374ad826e0a3284f737eb1d1e63f4398af 100644 (file)
@@ -22,6 +22,8 @@ FluidbookZoom.prototype = {
         var $this = this;
         this.setTransition(true);
 
+        this.initMouseWheel();
+
         $(this.fluidbook).on('fluidbook.zoom.out.end', function () {
             $("#z").addClass('nozoom');
         });
@@ -43,6 +45,44 @@ FluidbookZoom.prototype = {
         this.fluidbook.keyboard.initZoomShortcuts();
     },
 
+    initMouseWheel: function () {
+        var $this = this;
+        window.addEventListener('wheel', function (e) {
+            var returnValue = true;
+            if (e.ctrlKey) {
+                e.preventDefault();
+                e.stopPropagation();
+                e.stopImmediatePropagation();
+                returnValue = false;
+            }
+            if (!$this.enabled || $this.fluidbook.settings.zoomWheel === 'disabled') {
+                return returnValue;
+            }
+            if ($this.fluidbook.settings.zoomWheel === 'ctrlwheel' && !e.ctrlKey) {
+                return returnValue;
+            }
+            // Disable scroll zoom when either a view or the menu is open...
+            if ($("body").is('.view, .menu-open')) {
+                return returnValue;
+            }
+
+            $this.wheelZoom(e.deltaY * -1);
+            return returnValue;
+        }, {passive: false});
+    },
+
+    wheelZoom: function (delta) {
+        var dir;
+        if (delta > 0) {
+            delta = 0.7;
+            dir = 1;
+        } else {
+            delta = -0.7;
+            dir = -1;
+        }
+        this.setZoom(this.zoom + delta, dir);
+    },
+
     increaseZoom: function () {
         var z;
         if (this.zoom === 1) {