Skip to content

Commit

Permalink
Merge pull request #21 from doughballs/dev-branch
Browse files Browse the repository at this point in the history
fixed passive scroll listener for sidenav
  • Loading branch information
DanielRuf authored Dec 22, 2020
2 parents a8a30a3 + 3cbfb25 commit 57bfcdf
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,11 @@
this._handleCloseReleaseBound = this._handleCloseRelease.bind(this);
this._handleCloseTriggerClickBound = this._handleCloseTriggerClick.bind(this);

this.dragTarget.addEventListener('touchmove', this._handleDragTargetDragBound);
this.dragTarget.addEventListener('touchmove', this._handleDragTargetDragBound, passiveIfSupported);
this.dragTarget.addEventListener('touchend', this._handleDragTargetReleaseBound);
this._overlay.addEventListener('touchmove', this._handleCloseDragBound);
this._overlay.addEventListener('touchmove', this._handleCloseDragBound, passiveIfSupported);
this._overlay.addEventListener('touchend', this._handleCloseReleaseBound);
this.el.addEventListener('touchmove', this._handleCloseDragBound);
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 57bfcdf

Please sign in to comment.