Skip to content

Commit

Permalink
fix: Mark atom-utils event listeners as passive
Browse files Browse the repository at this point in the history
Marking event listeners as passive, indicates that the callback will
never call `event.preventDefault()`. This can greatly improve scrolling
performance.

For more information on passive event listeners see:
https://developers.google.com/web/updates/2016/06/passive-event-listeners

⚠️ This PR requires abe33/atom-utils#3 to
work correctly.

Co-authored-by: Lukas Geiger <lukas@plumerai.com>
  • Loading branch information
aminya and lgeiger committed Nov 22, 2020
1 parent a954c3f commit 9850bec
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/minimap-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ class MinimapElement {
this.subscriptions.add(this.subscribeTo(this.getFrontCanvas(), {
mousedown: (e) => { this.canvasPressed(this.extractMouseEventData(e)) },
touchstart: (e) => { this.canvasPressed(this.extractTouchEventData(e)) }
}))
}, { passive: true }))
}

/**
Expand All @@ -515,7 +515,7 @@ class MinimapElement {
this.visibleAreaSubscription = this.subscribeTo(this.visibleArea, {
mousedown: (e) => { this.startDrag(this.extractMouseEventData(e)) },
touchstart: (e) => { this.startDrag(this.extractTouchEventData(e)) }
})
}, { passive: true })

this.subscriptions.add(this.visibleAreaSubscription)
}
Expand Down
2 changes: 1 addition & 1 deletion lib/minimap-quick-settings-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class MinimapQuickSettingsElement {

subs.add(this.subscribeTo(this.hiddenInput, {
focusout: (e) => { this.destroy() }
}))
}, { passive: true }))

subs.add(this.subscribeTo(this.onLeftButton, {
mousedown: (e) => {
Expand Down

0 comments on commit 9850bec

Please sign in to comment.