Skip to content

Commit

Permalink
Expose public API to reset mouse cancelling for testing touch
Browse files Browse the repository at this point in the history
Remove undocument `event.__polymerSyntheticTouch` hack

Fixes #3540
  • Loading branch information
dfreedm committed Mar 29, 2016
1 parent e0bcda8 commit 18bf9d4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
18 changes: 16 additions & 2 deletions src/standard/gestures.html
Expand Up @@ -231,10 +231,10 @@
}
}
// disable synth mouse events, unless this event is itself simulated
if (type === 'touchend' && !ev.__polymerSimulatedTouch) {
if (type === 'touchend') {
POINTERSTATE.mouse.target = Polymer.dom(ev).rootTarget;
// ignore syntethic mouse events after a touch
ignoreMouse(true);
ignoreMouse();
}
}
}
Expand Down Expand Up @@ -404,6 +404,20 @@
if (recognizer.info) {
recognizer.info.prevent = true;
}
},
/**
* Reset the 2500ms timeout on processing mouse input after detecting touch input.
*
* Touch inputs create synthesized mouse inputs anywhere from 0 to 2000ms after the touch.
* This method should only be called during testing with simulated touch inputs.
* Calling this method in production may cause duplicate taps or other gestures.
*
* @method resetMouseCanceller
*/
resetMouseCanceller: function() {
if (POINTERSTATE.mouse.mouseIgnoreJob) {
POINTERSTATE.mouse.mouseIgnoreJob.complete();
}
}
};

Expand Down
3 changes: 1 addition & 2 deletions test/unit/gestures.html
Expand Up @@ -256,6 +256,7 @@
});
teardown(function() {
el.parentNode.removeChild(el);
Polymer.Gestures.resetMouseCanceller();
});

test('tap', function() {
Expand Down Expand Up @@ -313,7 +314,6 @@
];
ev.clientX = clientX;
ev.clientY = clientY;
ev.__polymerSimulatedTouch = true;
child.dispatchEvent(ev);

for (var i = 0; i < 10; i++) {
Expand All @@ -330,7 +330,6 @@
ev.clientX = clientX;
ev.clientY = clientY;
// tell gestures to not turn off mouse events
ev.__polymerSimulatedTouch = true;
child.dispatchEvent(ev);
}

Expand Down

0 comments on commit 18bf9d4

Please sign in to comment.