Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global setting to use click on tap handlers #5679

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/mixins/gesture-event-listeners.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import '../utils/boot.js';

import { dedupingMixin } from '../utils/mixin.js';
import { addListener, removeListener } from '../utils/gestures.js';
import { useClickOnTap } from '../utils/settings.js';

/**
* Element class mixin that provides API for adding Polymer's cross-platform
Expand Down Expand Up @@ -46,6 +47,10 @@ export const GestureEventListeners = dedupingMixin((superClass) => {
* @override
*/
_addEventListenerToNode(node, eventName, handler) {
if (useClickOnTap && eventName === 'tap') {
super._addEventListenerToNode(node, 'click', handler);
return;
}
if (!addListener(node, eventName, handler)) {
super._addEventListenerToNode(node, eventName, handler);
}
Expand All @@ -61,6 +66,10 @@ export const GestureEventListeners = dedupingMixin((superClass) => {
* @override
*/
_removeEventListenerFromNode(node, eventName, handler) {
if (useClickOnTap && eventName === 'tap') {
super._removeEventListenerFromNode(node, 'click', handler);
return;
}
if (!removeListener(node, eventName, handler)) {
super._removeEventListenerFromNode(node, eventName, handler);
}
Expand Down
8 changes: 8 additions & 0 deletions lib/utils/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ export const getSanitizeDOMValue = function() {
export let passiveTouchGestures =
window.Polymer && window.Polymer.setPassiveTouchGestures || false;

/**
* Globally settable property to make on-tap use on-click.
* Defaults to `false` for backwards compatibility.
*/
export const useClickOnTap =
window.Polymer && window.Polymer.useClickOnTap || false;


/**
* Sets `passiveTouchGestures` globally for all elements using Polymer Gestures.
*
Expand Down