Skip to content

Commit

Permalink
Merge pull request #683 from lgeiger/passive-event-handlers
Browse files Browse the repository at this point in the history
Make event listeners passive
  • Loading branch information
aminya authored Nov 21, 2020
2 parents 354e7ae + 5285870 commit c2c77e5
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/minimap-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ class MinimapElement {
elementResizeDetector.listenTo(this, measureDimensions)
this.subscriptions.add(new Disposable(() => { elementResizeDetector.removeListener(this, measureDimensions) }))

window.addEventListener('resize', measureDimensions)
window.addEventListener('resize', measureDimensions, { passive: true })
this.subscriptions.add(new Disposable(() => { window.removeEventListener('resize', measureDimensions) }))
}

Expand Down Expand Up @@ -1229,13 +1229,13 @@ class MinimapElement {
let touchmoveHandler = (e) => this.drag(this.extractTouchEventData(e), initial)
let touchendHandler = (e) => this.endDrag()

document.body.addEventListener('mousemove', mousemoveHandler)
document.body.addEventListener('mouseup', mouseupHandler)
document.body.addEventListener('mouseleave', mouseupHandler)
document.body.addEventListener('mousemove', mousemoveHandler, { passive: true })
document.body.addEventListener('mouseup', mouseupHandler, { passive: true })
document.body.addEventListener('mouseleave', mouseupHandler, { passive: true })

document.body.addEventListener('touchmove', touchmoveHandler)
document.body.addEventListener('touchend', touchendHandler)
document.body.addEventListener('touchcancel', touchendHandler)
document.body.addEventListener('touchmove', touchmoveHandler, { passive: true })
document.body.addEventListener('touchend', touchendHandler, { passive: true })
document.body.addEventListener('touchcancel', touchendHandler, { passive: true })

this.dragSubscription = new Disposable(function () {
document.body.removeEventListener('mousemove', mousemoveHandler)
Expand Down

0 comments on commit c2c77e5

Please sign in to comment.