Skip to content
This repository has been archived by the owner on Dec 19, 2024. It is now read-only.

Commit

Permalink
Ensure useCapture=true on M57 (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
valdrinkoshi authored Apr 18, 2017
1 parent 6d379de commit fcea5a1
Showing 1 changed file with 28 additions and 15 deletions.
43 changes: 28 additions & 15 deletions iron-dropdown-scroll-manager.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@
*/
var lastScrollableNodes = [];

var scrollEvents = [
// Modern `wheel` event for mouse wheel scrolling:
'wheel',
// Older, non-standard `mousewheel` event for some FF:
'mousewheel',
// IE:
'DOMMouseScroll',
// Touch enabled devices
'touchstart',
'touchmove'
];

/**
* The IronDropdownScrollManager is intended to provide a central source
* of authority and control over which elements in a document are currently
Expand Down Expand Up @@ -199,24 +211,25 @@
_lockScrollInteractions: function() {
this._boundScrollHandler = this._boundScrollHandler ||
this._scrollInteractionHandler.bind(this);
// Modern `wheel` event for mouse wheel scrolling:
document.addEventListener('wheel', this._boundScrollHandler, true);
// Older, non-standard `mousewheel` event for some FF:
document.addEventListener('mousewheel', this._boundScrollHandler, true);
// IE:
document.addEventListener('DOMMouseScroll', this._boundScrollHandler, true);
// Save the lastScrollableNodes on touchstart, to be used on touchmove.
document.addEventListener('touchstart', this._boundScrollHandler, true);
// Mobile devices can scroll on touch move:
document.addEventListener('touchmove', this._boundScrollHandler, true);
for (var i = 0, l = scrollEvents.length; i < l; i++) {
// NOTE: browsers that don't support objects as third arg will
// interpret it as boolean, hence useCapture = true in this case.
document.addEventListener(scrollEvents[i], this._boundScrollHandler, {
capture: true,
passive: false
});
}
},

_unlockScrollInteractions: function() {
document.removeEventListener('wheel', this._boundScrollHandler, true);
document.removeEventListener('mousewheel', this._boundScrollHandler, true);
document.removeEventListener('DOMMouseScroll', this._boundScrollHandler, true);
document.removeEventListener('touchstart', this._boundScrollHandler, true);
document.removeEventListener('touchmove', this._boundScrollHandler, true);
for (var i = 0, l = scrollEvents.length; i < l; i++) {
// NOTE: browsers that don't support objects as third arg will
// interpret it as boolean, hence useCapture = true in this case.
document.removeEventListener(scrollEvents[i], this._boundScrollHandler, {
capture: true,
passive: false
});
}
},

/**
Expand Down

0 comments on commit fcea5a1

Please sign in to comment.