]> _ Git - fluidbook-html5.git/commitdiff
wait #2816 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 3 Jun 2019 17:13:37 +0000 (19:13 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 3 Jun 2019 17:13:37 +0000 (19:13 +0200)
js/libs/fluidbook/fluidbook.interface.js
js/libs/fluidbook/fluidbook.touch.js

index 2aa538a72904501e7e234338e103390552726e06..eac35609d05d79ab65f5b61555af79f073fdc924 100644 (file)
@@ -6,6 +6,8 @@ function FluidbookInterface(fluidbook) {
     this.visibleTime = 5000;
     this.interfaceVisible = false;
 
+    this.maskToggleEventsTimeout = Date.now();
+
     this.init();
 }
 
@@ -51,24 +53,33 @@ FluidbookInterface.prototype = {
     },
 
     initArrowsVisibilityManagement: function () {
+        console.log('init arrows visi manag');
         var $this = this;
 
         this.getInterfaceSelector().addClass('interfacecomponent');
 
-        $(document).on('click', '#z', function () {
-            $this.toggleInterface();
-            return true;
-        });
-
         if (this.autoHideArrows()) {
-            $(document).on('click', ':not(a)', function () {
-                var selector = '#background,header,footer';
-                if (!$(this).is(selector) && $(this).closest(selector).length === 0) {
+            if (this.fluidbook.touch) {
+                this.fluidbook.touch.hm.on('singletap', function (event) {
+                    var target = $(event.target);
+                    if (target.is('a') || target.closest('a').length > 0) {
+                        return true;
+                    }
+                    $this.toggleInterface(1000);
                     return true;
-                }
-                $this.toggleInterface();
-                return true;
-            });
+                });
+            } else {
+                $(document).on('click', ':not(a)', function () {
+                    var selector = '#fluidbook';
+                    if (!$(this).is(selector) && $(this).closest(selector).length === 0) {
+                        console.log('nok', $(this));
+                        return true;
+                    }
+                    console.log('ok', $(this));
+                    $this.toggleInterface(1000);
+                    return true;
+                });
+            }
         }
 
         $(this.fluidbook).on('fluidbook.ready', function () {
@@ -79,7 +90,19 @@ FluidbookInterface.prototype = {
         this.checkHidden();
     },
 
-    toggleInterface: function () {
+    toggleInterface: function (mask) {
+        if (mask === undefined) {
+            mask = 0;
+        }
+
+        var now = Date.now();
+        if (now < this.maskToggleEventsTimeout) {
+            return;
+        }
+        if (mask > 0) {
+            this.maskToggleEventsTimeout = Math.max(this.maskToggleEventsTimeout, Date.now() + mask);
+        }
+
         if (this.interfaceVisible && this.autoHideArrows()) {
             return this.hideInterface();
         } else {
index 8458a7a13f6c4b61b24d722daa709889a9ab3c8d..4d72e1b1e067056a07f5173d825046dbe0fe1ff2 100644 (file)
@@ -38,6 +38,7 @@ FluidbookTouch.prototype = {
     },
 
     initInteract: function () {
+        var tapEnabled = true;
         var pinchEnabled = true;
         var doubletapEnabled = true;
         var panEnabled = true;
@@ -49,7 +50,7 @@ FluidbookTouch.prototype = {
 
         var $this = this;
 
-        if (!doubletapEnabled && !panEnabled && !pinchEnabled) {
+        if (!tapEnabled && !doubletapEnabled && !panEnabled && !pinchEnabled) {
             return;
         }
 
@@ -61,11 +62,16 @@ FluidbookTouch.prototype = {
         Hammer.defaults.touchAction = options.touchAction;
 
         var hm = new Hammer.Manager(document.getElementById('main'), options);
+        this.hm = hm;
 
         if (doubletapEnabled) {
             hm.add(new Hammer.Tap({event: 'doubletap', taps: 2, interval: 500}));
         }
 
+        if (tapEnabled) {
+            hm.add(new Hammer.Tap({event: 'singletap', taps: 1, interval: 500}));
+        }
+
         if (pinchEnabled) {
             hm.add(new Hammer.Pinch({threshold: 0}));
             hm.get('pinch').set({enable: true});