this.offsetX = 0;
this.offsetY = 0;
+ this.zoomAtPinchStart = 0;
+
this.triggerOffset = 0.05;
this.init();
}
event.preventDefault();
});
+ hm.on('pinchstart', function (event) {
+ console.log('start');
+ $this.zoomAtPinchStart = $this.fluidbook.zoom.zoom;
+ $this.pinchZoom(event.scale, true);
+ event.preventDefault();
+ });
hm.on('pinch', function (event) {
- console.log(event);
+ console.log('pinch');
+ if ($this.zoomAtPinchStart != 0) {
+ $this.pinchZoom(event.scale, false);
+ event.preventDefault();
+ }
+ })
+ hm.on('pinchend pinchcancel', function (event) {
+ console.log('end');
+ $this.pinchZoom(event.scale, true);
+ $this.zoomAtPinchStart = 0;
event.preventDefault();
});
});
},*/
- pinchZoom: function (s) {
+ pinchZoom: function (s, end) {
this.fluidbook.zoom.setTransition(false);
- this.fluidbook.zoom.setZoom(s, undefined);
+ var amplitudeRegulation = 0.25;
+ var dir;
+ if (s > 1) {
+ s = 1 + ((s - 1) * amplitudeRegulation);
+ dir = 1;
+ } else if (s < 1) {
+ var amplitude = (1 - s) * amplitudeRegulation;
+ s = 1 - amplitude;
+ dir = -1;
+ }
+
+
+ this.fluidbook.zoom.setZoom(this.zoomAtPinchStart * s, dir, end);
},
dragzoom: function (e) {
* @param zoom Zoom level
* @param direction Zoom direction (1=zoom in, -1=zoom out)
*/
- setZoom: function (zoom, direction) {
+
+
+ setZoom: function (zoom, direction, end) {
+ if (end == undefined) {
+ end = false;
+ }
if (direction == undefined) {
if (this.zoom > zoom) {
direction = -1;
if (this.zoom == zoom) {
return;
}
- if (!this.transition) {
+ if (!this.transition && end == true) {
+
if (direction == 1) {
if (zoom < 1.25) {
zoom = 2;
this.setTransition(true);
}
}
+
}
if (this.zoom == zoom) {
return;