Skip to content

Commit

Permalink
Fix list:
Browse files Browse the repository at this point in the history
fix double events pointer/touch on Chrome >=55 timmywil#303
Unable to preventDefault inside passive event listener due to target being treated as passive. timmywil#328
  • Loading branch information
inuyaksa committed Jun 28, 2017
1 parent 8e752a7 commit f3cafa2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
19 changes: 12 additions & 7 deletions dist/jquery.panzoom.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @license jquery.panzoom.js v3.2.2
* Updated: Wed Jun 21 2017
* Updated: Wed Jun 28 2017
* Add pan and zoom functionality to any element
* Copyright (c) timmy willison
* Released under the MIT license
Expand Down Expand Up @@ -970,7 +970,7 @@
if (!options.disablePan || !options.disableZoom) {
events[ str_start ] = function(e) {
var touches;
if (e.type === 'touchstart' ?
if (/touchstart|pointerdown/.test(e.type) ? // fix double events pointer/touch on Chrome >=55 #303
// Touch
(touches = e.touches || e.originalEvent.touches) &&
((touches.length === 1 && !options.disablePan) || touches.length === 2) :
Expand Down Expand Up @@ -1138,6 +1138,12 @@
if (this.panning) {
return;
}

var type = event.type;
if (window.PointerEvent && (type === 'touchstart')) { // fix double events pointer/touch on Chrome >=55 #303
// return false;
}

var moveEvent, endEvent,
startDistance, startScale, startMiddle,
startPageX, startPageY, touch;
Expand All @@ -1149,7 +1155,6 @@
var origPageX = +original[4];
var origPageY = +original[5];
var panOptions = { matrix: matrix, animate: 'skip' };
var type = event.type;

// Use proper events
if (type === 'pointerdown') {
Expand All @@ -1173,9 +1178,6 @@
// Remove any transitions happening
this.transition(true);

// Indicate that we are currently panning
this.panning = true;

// Trigger start event
this._trigger('start', event, touches);

Expand Down Expand Up @@ -1209,7 +1211,7 @@

var move = function(e) {
var coords;
e.preventDefault();
e.stopPropagation(); // chrome passive event warning https://www.chromestatus.com/features/5093566007214080 #328
touches = e.touches || e.originalEvent.touches;
setStart(e, touches);

Expand Down Expand Up @@ -1243,6 +1245,9 @@
coords = e;
}

// Indicate that we are currently panning
this.panning = true;

self.pan(
origPageX + coords.pageX - startPageX,
origPageY + coords.pageY - startPageY,
Expand Down

0 comments on commit f3cafa2

Please sign in to comment.