Skip to content

Commit

Permalink
Handle events in capture phase rather than bubbling phase (#126)
Browse files Browse the repository at this point in the history
* change event listeners to trigger in capture phase rather than bubble phase

* dist files

Co-authored-by: Joy Kim <[email protected]>
  • Loading branch information
jojo080889 and Joy Kim authored Apr 20, 2022
1 parent d489b9a commit e7e2bf5
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 deletions.
26 changes: 13 additions & 13 deletions dist/what-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,39 +195,39 @@ return /******/ (function(modules) { // webpackBootstrap
// `pointermove`, `MSPointerMove`, `mousemove` and mouse wheel event binding
// can only demonstrate potential, but not actual, interaction
// and are treated separately
var options = supportsPassive ? { passive: true } : false;
var options = supportsPassive ? { passive: true, capture: true } : true;

document.addEventListener('DOMContentLoaded', setPersist);
document.addEventListener('DOMContentLoaded', setPersist, true);

// pointer events (mouse, pen, touch)
if (window.PointerEvent) {
window.addEventListener('pointerdown', setInput);
window.addEventListener('pointermove', setIntent);
window.addEventListener('pointerdown', setInput, true);
window.addEventListener('pointermove', setIntent, true);
} else if (window.MSPointerEvent) {
window.addEventListener('MSPointerDown', setInput);
window.addEventListener('MSPointerMove', setIntent);
window.addEventListener('MSPointerDown', setInput, true);
window.addEventListener('MSPointerMove', setIntent, true);
} else {
// mouse events
window.addEventListener('mousedown', setInput);
window.addEventListener('mousemove', setIntent);
window.addEventListener('mousedown', setInput, true);
window.addEventListener('mousemove', setIntent, true);

// touch events
if ('ontouchstart' in window) {
window.addEventListener('touchstart', setInput, options);
window.addEventListener('touchend', setInput);
window.addEventListener('touchend', setInput, true);
}
}

// mouse wheel
window.addEventListener(detectWheel(), setIntent, options);

// keyboard events
window.addEventListener('keydown', setInput);
window.addEventListener('keyup', setInput);
window.addEventListener('keydown', setInput, true);
window.addEventListener('keyup', setInput, true);

// focus events
window.addEventListener('focusin', setElement);
window.addEventListener('focusout', clearElement);
window.addEventListener('focusin', setElement, true);
window.addEventListener('focusout', clearElement, true);
};

// checks if input persistence should happen and
Expand Down
2 changes: 1 addition & 1 deletion dist/what-input.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e7e2bf5

Please sign in to comment.