From b9fe2b389ee06e5e967c23235ddc4d8421fb7959 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Mon, 3 Jun 2019 19:13:37 +0200 Subject: [PATCH] wait #2816 @1 --- js/libs/fluidbook/fluidbook.interface.js | 49 +++++++++++++++++------- js/libs/fluidbook/fluidbook.touch.js | 8 +++- 2 files changed, 43 insertions(+), 14 deletions(-) diff --git a/js/libs/fluidbook/fluidbook.interface.js b/js/libs/fluidbook/fluidbook.interface.js index 2aa538a7..eac35609 100644 --- a/js/libs/fluidbook/fluidbook.interface.js +++ b/js/libs/fluidbook/fluidbook.interface.js @@ -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 { diff --git a/js/libs/fluidbook/fluidbook.touch.js b/js/libs/fluidbook/fluidbook.touch.js index 8458a7a1..4d72e1b1 100644 --- a/js/libs/fluidbook/fluidbook.touch.js +++ b/js/libs/fluidbook/fluidbook.touch.js @@ -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}); -- 2.39.5