From f3f062585d97b49151514ced59a694a095c0a558 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 20 Jul 2017 18:10:04 +0200 Subject: [PATCH] wip #1487 @5 --- js/libs/fluidbook/fluidbook.desktop.js | 6 ++++++ js/libs/fluidbook/fluidbook.js | 5 +++-- js/libs/fluidbook/fluidbook.touch.js | 16 ++++++++++------ js/libs/fluidbook/fluidbook.zoom.js | 5 +++-- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/js/libs/fluidbook/fluidbook.desktop.js b/js/libs/fluidbook/fluidbook.desktop.js index 14c7e48f..4d40501c 100644 --- a/js/libs/fluidbook/fluidbook.desktop.js +++ b/js/libs/fluidbook/fluidbook.desktop.js @@ -6,6 +6,12 @@ function FluidbookDesktop(fluidbook) { FluidbookDesktop.prototype = { init: function () { var $this = this; + $(document).on('touchend', '#links', function (e) { + // If we are touching the #links, we prevent mouse event emulation in order to prevent zoom on single tap event + if ($(e.target).is('#links')) { + e.preventDefault(); + } + }); $(document).on('click', '#links', function (e) { $this.clickZoom(e); return false; diff --git a/js/libs/fluidbook/fluidbook.js b/js/libs/fluidbook/fluidbook.js index ccff34dc..030840c3 100644 --- a/js/libs/fluidbook/fluidbook.js +++ b/js/libs/fluidbook/fluidbook.js @@ -38,7 +38,8 @@ Fluidbook.prototype = { this.waiters = []; this.viewport = new FluidbookViewport(this); this.viewport.updateViewport(); - if (/*Modernizr.ftouch &&*/ this.support.transitions2d && this.datas.mobileTransitions != 'none') { + this.desktop = new FluidbookDesktop(this); + if (Modernizr.ftouch && this.support.transitions2d && this.datas.mobileTransitions != 'none') { this.touch = new FluidbookTouch(this); } this.background = new FluidbookBackground(this); @@ -81,7 +82,7 @@ Fluidbook.prototype = { this.coquillette = new FluidbookCoquillette(this); this.stats = new FluidbookStats(this); this.stats.track(10); - this.desktop = new FluidbookDesktop(this); + this.initTheme(); this.initKeyboardShortcuts(); diff --git a/js/libs/fluidbook/fluidbook.touch.js b/js/libs/fluidbook/fluidbook.touch.js index 6607e62e..c3d044c4 100644 --- a/js/libs/fluidbook/fluidbook.touch.js +++ b/js/libs/fluidbook/fluidbook.touch.js @@ -40,14 +40,13 @@ FluidbookTouch.prototype = { initInteract: function () { var $this = this; - // Double tap - var hm = new Hammer.Manager(document.getElementById('fluidbook'), {domEvents: false}); + var hm = new Hammer.Manager(document.getElementById('main'), {domEvents: false}); hm.add(new Hammer.Tap({event: 'doubletap', taps: 2, interval: 500})); hm.add(new Hammer.Pinch({threshold: 0})); - hm.add(new Hammer.Pan({threshold: 0})); hm.get('pinch').set({enable: true}); + + // Double tap hm.on('doubletap', function (event) { - console.log(event); if ($this.fluidbook.zoom.zoom > 1) { $this.fluidbook.zoom.setTransition(true); $this.fluidbook.zoom.resetZoom(); @@ -59,12 +58,14 @@ FluidbookTouch.prototype = { event.preventDefault(); }); // Pinch + hm.on('pinchstart', function (event) { $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('pinch', function (event) { if ($this.zoomAtPinchStart != 0) { $this.pinchZoom(event.scale, false); @@ -76,11 +77,14 @@ FluidbookTouch.prototype = { $this.zoomAtPinchStart = $this.fluidbook.zoom.zoom; event.preventDefault(); }); - hm.on('panmove', function (event) { + + var hmf = new Hammer.Manager(document.getElementById('fluidbook'), {domEvents: false}); + hmf.add(new Hammer.Pan({threshold: 0})); + hmf.on('panmove', function (event) { $this.drag(event); event.preventDefault(); }); - hm.on('panend', function (event) { + hmf.on('panend', function (event) { $this.drag(event, true); $this.startX = $this.startY = -1; $this.panX = $this.panY = 0; diff --git a/js/libs/fluidbook/fluidbook.zoom.js b/js/libs/fluidbook/fluidbook.zoom.js index 7d2c914e..6c2e5015 100644 --- a/js/libs/fluidbook/fluidbook.zoom.js +++ b/js/libs/fluidbook/fluidbook.zoom.js @@ -86,9 +86,9 @@ FluidbookZoom.prototype = { } if (transition == false) { - $("#z").addClass('notransition').removeClass('transition'); + $("#z").addClass('notransition').removeClass('transition').removeClass('transition-inertia'); } else { - $("#z").removeClass('notransition'); + $("#z").removeClass('notransition').removeClass('transition-inertia'); } this.transition = transition; }, @@ -153,6 +153,7 @@ FluidbookZoom.prototype = { } $("#z").transform(animation); $this.triggerEvent(((this.zoom == 1) ? 'out' : 'in') + '.start'); + if (!this.transition) { $this.triggerEvent(((this.zoom == 1) ? 'out' : 'in') + '.end'); } -- 2.39.5