0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-12-01 11:41:20 +01:00

replace classic logical fallacy in touch event detection with the recommended solution.

This commit is contained in:
Josh Barr 2016-03-22 18:47:50 +13:00 committed by Karl Hobley
parent 9bdc843c8f
commit 0b9f78ef9d

View File

@ -6,7 +6,7 @@ document.addEventListener('DOMContentLoaded', function userBar(e) {
var list = userbar.querySelector('.wagtail-userbar-items');
var className = 'is-active';
var hasTouch = 'ontouchstart' in window;
var clickEvent = hasTouch ? 'touchstart' : 'click';
var clickEvent = 'click';
if (!'classList' in userbar) {
return;
@ -14,6 +14,14 @@ document.addEventListener('DOMContentLoaded', function userBar(e) {
if (hasTouch) {
userbar.classList.add('touch');
// Bind to touchend event, preventDefault to prevent DELAY and CLICK
// in accordance with: https://hacks.mozilla.org/2013/04/detecting-touch-its-the-why-not-the-how/
trigger.addEventListener('touchend', function preventSimulatedClick(e) {
e.preventDefault();
toggleUserbar();
});
} else {
userbar.classList.add('no-touch');
}