]> _ Git - fluidbook-html5.git/commitdiff
wip #1487 @5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 20 Jul 2017 16:10:04 +0000 (18:10 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 20 Jul 2017 16:10:04 +0000 (18:10 +0200)
js/libs/fluidbook/fluidbook.desktop.js
js/libs/fluidbook/fluidbook.js
js/libs/fluidbook/fluidbook.touch.js
js/libs/fluidbook/fluidbook.zoom.js

index 14c7e48f5509186f971549ca0b1173fa5990b9b0..4d40501c0429aa2596be3b18eec3e6eb4bfac891 100644 (file)
@@ -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;
index ccff34dc921b40c364d033c1982d000a3ceb8973..030840c3ea82f92a9614e138ee172d4a54d772ac 100644 (file)
@@ -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();
index 6607e62e19b89453cbc3ac8fe6fdbd3f0b138e89..c3d044c4247b3ab79bbddadfecdc47e905d3734c 100644 (file)
@@ -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;
index 7d2c914efb29478c7381501b8f2762d0850363e3..6c2e501548aa6025ea6860ffbc830cb0bf847eac 100644 (file)
@@ -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');
         }