]> _ Git - fluidbook-html5.git/commitdiff
wip #2286 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 16 Oct 2018 12:55:47 +0000 (14:55 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 16 Oct 2018 12:55:47 +0000 (14:55 +0200)
js/libs/fluidbook/links/fluidbook.links.zoomhd.js

index 97fa3dc87bc6aaad637a61d2c624faa7a88a95be..5c7f54754093d37bc881588a0dad952eddffeff0 100644 (file)
@@ -10,6 +10,8 @@ function FluidbookLinksZoomHD(fluidbook) {
     this.aw;
 
     this.draging = false;
+    this.scaling = true;
+    this.pinchScale = 1;
     this.dragX = 0;
     this.dragY = 0;
     this.dragMinX = 0;
@@ -106,6 +108,8 @@ FluidbookLinksZoomHD.prototype = {
         var mc = new Hammer(h.get(0));
 
         mc.get('pan').set({direction: Hammer.DIRECTION_ALL});
+        mc.get('pinch').set({enable: true});
+
         mc.on('pan', function (e) {
             if ($this.scale == 1) {
                 return false;
@@ -119,7 +123,6 @@ FluidbookLinksZoomHD.prototype = {
 
             $this.setMovePos($this.dragX + e.deltaX, $this.dragY + e.deltaY);
 
-
             if (e.isFinal) {
                 $this.dragging = false;
                 $this.dragX = $this.dragY = 0;
@@ -127,6 +130,20 @@ FluidbookLinksZoomHD.prototype = {
             return false;
         });
 
+        mc.on('pinch', function (e) {
+            if (!this.scaling) {
+                $this.scaling = true;
+                $this.pinchScale = $this.scale;
+            }
+
+            $this.scale = $this.normalizeScale($this.scale + ((e.scale - 1) * 0.1));
+            $this.resize();
+
+            if (e.isFinal) {
+                $this.scaling = false;
+            }
+        });
+
         i.css(
             {
                 left: this.image.naturalWidth / -2,