From d1ce1dbef22a2e412d622a2ae0b5699054228ad6 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Tue, 16 Oct 2018 14:55:47 +0200 Subject: [PATCH] wip #2286 @1 --- .../fluidbook/links/fluidbook.links.zoomhd.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/js/libs/fluidbook/links/fluidbook.links.zoomhd.js b/js/libs/fluidbook/links/fluidbook.links.zoomhd.js index 97fa3dc8..5c7f5475 100644 --- a/js/libs/fluidbook/links/fluidbook.links.zoomhd.js +++ b/js/libs/fluidbook/links/fluidbook.links.zoomhd.js @@ -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, -- 2.39.5