]> _ Git - fluidbook-html5.git/commitdiff
wip #2657 @3
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 4 Apr 2019 17:49:54 +0000 (19:49 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 4 Apr 2019 17:49:54 +0000 (19:49 +0200)
js/libs/fluidbook/fluidbook.touch.js
style/mobilefirst.less

index 9dce2ddff94fca2d64cc456032a501c5ee37905e..fa968b918c1cc6efd3d4daf1b49044d5905cea3f 100644 (file)
@@ -40,7 +40,14 @@ FluidbookTouch.prototype = {
     initInteract: function () {
         var $this = this;
 
-        var hm = new Hammer.Manager(document.getElementById('main'), {domEvents: false});
+        var options = {
+            domEvents: this.fluidbook.mobilefirst.enabled,
+            touchAction: 'compute'
+        };
+        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});
@@ -84,11 +91,12 @@ FluidbookTouch.prototype = {
             event.preventDefault();
         });
 
-        var hmf = new Hammer.Manager(document.getElementById('fluidbook'), {domEvents: false});
+        var hmf = new Hammer.Manager(document.getElementById('fluidbook'), options);
         hmf.add(new Hammer.Pan({threshold: 0}));
         hmf.on('panmove', function (event) {
             console.log('panmove');
             if ($this.drag(event)) {
+                console.log('prevent scroll')
                 event.preventDefault();
             }
         });
@@ -128,17 +136,17 @@ FluidbookTouch.prototype = {
         if (end == undefined) {
             end = false;
         }
-        if (this.fluidbook.zoom.zoom == 1) {
-            if (this.startX == -1) {
+        if (this.fluidbook.zoom.zoom === 1) {
+            if (this.startX === -1) {
                 this.startX = e.center.x;
             }
-            if (this.startY == -1) {
+            if (this.startY === -1) {
                 this.startY = e.center.y;
             }
             this.offsetX = (e.center.x - this.startX) / this.fluidbook.resize.ww;
             this.offsetY = (e.center.y - this.startY) / this.fluidbook.resize.hh;
 
-            this.testSlideOffset();
+            return this.testSlideOffset();
         } else {
             this.resetSlide();
             if (end) {
@@ -148,6 +156,7 @@ FluidbookTouch.prototype = {
             } else {
                 this.dragZoom(e, end);
             }
+            return true;
         }
     },
 
@@ -178,8 +187,9 @@ FluidbookTouch.prototype = {
             if (Math.abs(this.offsetX) < Math.abs(this.offsetY)) {
                 return false;
             }
+            var ltr = this.fluidbook.l10n.dir === 'ltr';
             if (this.offsetX < -this.triggerOffset) {
-                if (this.fluidbook.l10n.dir == 'ltr') {
+                if (ltr) {
                     this.fluidbook.goNextPage();
                     this.resetSlide();
                 } else {
@@ -189,7 +199,7 @@ FluidbookTouch.prototype = {
 
                 return true;
             } else if (this.offsetX > this.triggerOffset) {
-                if (this.fluidbook.l10n.dir == 'ltr') {
+                if (ltr) {
                     this.fluidbook.goPreviousPage();
                     this.resetSlide();
                 } else {
@@ -213,7 +223,7 @@ FluidbookTouch.prototype = {
             }
 
             if (offset < -this.triggerOffset) {
-                if (way == 'x') {
+                if (way === 'x') {
                     this.fluidbook.goNextChapter();
                     this.resetSlide();
                 } else {
@@ -221,7 +231,7 @@ FluidbookTouch.prototype = {
                     this.resetSlide();
                 }
             } else {
-                if (way == 'x') {
+                if (way === 'x') {
                     this.fluidbook.goPreviousChapter();
                     this.resetSlide();
                 } else {
index acb337ec813075e3095a4fecaa712b12c5f2baf0..f487a348071dfaf6a717a985e1e5ee5cdd13ae57 100644 (file)
       opacity: @shadow-opacity*0.25;
     }
   }
+
+  #fluidbook, #main {
+    touch-action: auto !important;
+  }
+
+  .zoomed {
+    #fluidbook, #main {
+      touch-action: none !important;
+    }
+  }
 }
 
 .mf-nav {