mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-19 04:31:11 +00:00
replace classic logical fallacy in touch event detection with the recommended solution.
This commit is contained in:
parent
38e1fe7735
commit
2ce9bda1a3
1 changed files with 9 additions and 1 deletions
|
|
@ -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');
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue