]> _ Git - fluidbook-html5.git/commitdiff
fix #2813 @2
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 3 Jun 2019 12:31:50 +0000 (14:31 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 3 Jun 2019 12:31:50 +0000 (14:31 +0200)
js/libs/fluidbook/fluidbook.touch.js
style/mixins.less

index 5b633d2a34b645e8a627245d324baac4b94abe4a..8458a7a13f6c4b61b24d722daa709889a9ab3c8d 100644 (file)
@@ -38,82 +38,108 @@ FluidbookTouch.prototype = {
     },
 
     initInteract: function () {
+        var pinchEnabled = true;
+        var doubletapEnabled = true;
+        var panEnabled = true;
+        var touchAction = 'compute';
+
+        if (this.fluidbook.mobilefirst.enabled) {
+            touchAction = 'auto';
+        }
+
         var $this = this;
 
+        if (!doubletapEnabled && !panEnabled && !pinchEnabled) {
+            return;
+        }
+
         var options = {
             domEvents: this.fluidbook.mobilefirst.enabled,
-            touchAction: 'compute'
+            touchAction: touchAction
         };
         Hammer.defaults.domEvents = options.domEvents;
         Hammer.defaults.touchAction = options.touchAction;
 
         var hm = new Hammer.Manager(document.getElementById('main'), options);
-        hm.add(new Hammer.Tap({event: 'doubletap', taps: 2, interval: 500}));
-        hm.add(new Hammer.Pinch({threshold: 0}));
-        hm.get('pinch').set({enable: true});
-
-        // Double tap
-        hm.on('doubletap', function (event) {
-            console.log('doubletap');
-            if ($this.fluidbook.zoom.enabled) {
-                if ($this.fluidbook.zoom.zoom > 1) {
-                    $this.fluidbook.zoom.setTransition(true);
-                    $this.fluidbook.zoom.resetZoom();
-                } else {
-                    $this.setZoomOriginFromEvent(event.srcEvent);
-                    $this.fluidbook.zoom.setTransition(true);
-                    $this.fluidbook.zoom.setZoom($this.fluidbook.datas.zoom / 100, 1)
-                }
-            }
-            event.preventDefault();
-        });
 
-        // Pinch
-        hm.on('pinchstart', function (event) {
-            if ($this.fluidbook.zoom.enabled) {
-                if ($this.fluidbook.zoom.zoom === 1) {
-                    $this.setZoomOriginFromEvent({'pageX': event.center.x, 'pageY': event.center.y});
+        if (doubletapEnabled) {
+            hm.add(new Hammer.Tap({event: 'doubletap', taps: 2, interval: 500}));
+        }
+
+        if (pinchEnabled) {
+            hm.add(new Hammer.Pinch({threshold: 0}));
+            hm.get('pinch').set({enable: true});
+        }
+
+        if (doubletapEnabled) {
+            // Double tap
+            hm.on('doubletap', function (event) {
+                console.log('doubletap');
+                if ($this.fluidbook.zoom.enabled) {
+                    if ($this.fluidbook.zoom.zoom > 1) {
+                        $this.fluidbook.zoom.setTransition(true);
+                        $this.fluidbook.zoom.resetZoom();
+                    } else {
+                        $this.setZoomOriginFromEvent(event.srcEvent);
+                        $this.fluidbook.zoom.setTransition(true);
+                        $this.fluidbook.zoom.setZoom($this.fluidbook.datas.zoom / 100, 1)
+                    }
                 }
-                $this.zoomAtPinchStart = $this.fluidbook.zoom.zoom;
-                $this.pinchZoom(event.scale, false);
-            }
-            event.preventDefault();
-        });
+                event.preventDefault();
+            });
+        }
+
+        if (pinchEnabled) {
 
-        hm.on('pinch', function (event) {
-            if ($this.fluidbook.zoom.enabled) {
-                console.log('pinch');
-                if ($this.zoomAtPinchStart !== 0) {
+            // Pinch
+            hm.on('pinchstart', function (event) {
+                if ($this.fluidbook.zoom.enabled) {
+                    if ($this.fluidbook.zoom.zoom === 1) {
+                        $this.setZoomOriginFromEvent({'pageX': event.center.x, 'pageY': event.center.y});
+                    }
+                    $this.zoomAtPinchStart = $this.fluidbook.zoom.zoom;
                     $this.pinchZoom(event.scale, false);
-                    event.preventDefault();
                 }
-            }
-        });
-        hm.on('pinchend pinchcancel', function (event) {
-            if ($this.fluidbook.zoom.enabled) {
-                console.log('pinchend');
-                $this.pinchZoom(event.scale, true);
-                $this.zoomAtPinchStart = $this.fluidbook.zoom.zoom;
-            }
-            event.preventDefault();
-        });
-
-        var hmf = new Hammer.Manager(document.getElementById('fluidbook'), options);
-        hmf.add(new Hammer.Pan({threshold: 0}));
-        hmf.on('panmove', function (event) {
-            if ($this.drag(event)) {
-                console.log('prevent scroll')
                 event.preventDefault();
-            }
-        });
-        hmf.on('panend', function (event) {
-            var prevent = $this.drag(event, true);
-            $this.startX = $this.startY = -1;
-            $this.panX = $this.panY = 0;
-            if (prevent) {
+            });
+
+            hm.on('pinch', function (event) {
+                if ($this.fluidbook.zoom.enabled) {
+                    console.log('pinch');
+                    if ($this.zoomAtPinchStart !== 0) {
+                        $this.pinchZoom(event.scale, false);
+                        event.preventDefault();
+                    }
+                }
+            });
+            hm.on('pinchend pinchcancel', function (event) {
+                if ($this.fluidbook.zoom.enabled) {
+                    console.log('pinchend');
+                    $this.pinchZoom(event.scale, true);
+                    $this.zoomAtPinchStart = $this.fluidbook.zoom.zoom;
+                }
                 event.preventDefault();
-            }
-        });
+            });
+        }
+
+        if (panEnabled) {
+            var hmf = new Hammer.Manager(document.getElementById('fluidbook'), options);
+            hmf.add(new Hammer.Pan({threshold: 0}));
+            hmf.on('panmove', function (event) {
+                if ($this.drag(event)) {
+                    console.log('prevent scroll')
+                    event.preventDefault();
+                }
+            });
+            hmf.on('panend', function (event) {
+                var prevent = $this.drag(event, true);
+                $this.startX = $this.startY = -1;
+                $this.panX = $this.panY = 0;
+                if (prevent) {
+                    event.preventDefault();
+                }
+            });
+        }
     },
 
     pinchZoom: function (s, end) {
index b2e9e7d35fde989fc97af37a9a6cff28d03d6296..7f1a55c2873d927e9e25e45f64a8c54817f089de 100644 (file)
@@ -78,4 +78,5 @@
   &::-webkit-scrollbar {
     display: none;
   }
+  -webkit-overflow-scrolling: touch;
 }
\ No newline at end of file