Skip to content

Commit

Permalink
Moved passive IE feature detection function to Global.js, so that it …
Browse files Browse the repository at this point in the history
…can be used anywhere (currently also being used by waves.js), and adjusted sidenav.js to included the new function
  • Loading branch information
doughballs committed Sep 26, 2020
1 parent 95580a5 commit 3cbfb25
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
10 changes: 10 additions & 0 deletions js/global.js
Expand Up @@ -442,3 +442,13 @@ M.throttle = function(func, wait, options) {
return result;
};
};

/* Feature detection */
var passiveIfSupported = false;
try {
window.addEventListener("test", null,
Object.defineProperty({}, "passive", {
get: function() { passiveIfSupported = { passive: false }; }
}
));
} catch(err) {}
6 changes: 3 additions & 3 deletions js/sidenav.js
Expand Up @@ -129,11 +129,11 @@
this._handleCloseReleaseBound = this._handleCloseRelease.bind(this);
this._handleCloseTriggerClickBound = this._handleCloseTriggerClick.bind(this);

this.dragTarget.addEventListener('touchmove', this._handleDragTargetDragBound, { passive: true});
this.dragTarget.addEventListener('touchmove', this._handleDragTargetDragBound, passiveIfSupported);
this.dragTarget.addEventListener('touchend', this._handleDragTargetReleaseBound);
this._overlay.addEventListener('touchmove', this._handleCloseDragBound, { passive: true});
this._overlay.addEventListener('touchmove', this._handleCloseDragBound, passiveIfSupported);
this._overlay.addEventListener('touchend', this._handleCloseReleaseBound);
this.el.addEventListener('touchmove', this._handleCloseDragBound, { passive: true});
this.el.addEventListener('touchmove', this._handleCloseDragBound, passiveIfSupported);
this.el.addEventListener('touchend', this._handleCloseReleaseBound);
this.el.addEventListener('click', this._handleCloseTriggerClickBound);

Expand Down

0 comments on commit 3cbfb25

Please sign in to comment.