Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add possibility to pass options to addEventListener #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lgeiger
Copy link

@lgeiger lgeiger commented Feb 15, 2019

This allows users to pass options to addEventListener. This is especially usefull when using passive event listeners which can greatly improve scrolling performance. See atom-minimap/minimap#683

@@ -26,7 +26,7 @@ class EventsDelegation extends Mixin
eachPair events, (event, callback) =>
unless eventsForObject[event]?
eventsForObject[event] = {}
disposablesForObject[event] = @createEventListener(object, event)
disposablesForObject[event] = @createEventListener(object, event, options)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also enable users to define options on an event by event basis but I guess this API is nicer for most of the use cases.

This allows users to pass options to [`addEventListener`](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Parameters). This is especially usefull when using passive event listeners which can greatly improve scrolling performance. See atom-minimap/minimap#683
@lgeiger lgeiger force-pushed the event-listener-options branch from f981874 to 6f0ac87 Compare February 15, 2019 20:27
lgeiger added a commit to lgeiger/minimap that referenced this pull request Feb 15, 2019
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.
@lgeiger
Copy link
Author

lgeiger commented Feb 15, 2019

Checkout atom-minimap/minimap#684 for an example usage.

@lgeiger
Copy link
Author

lgeiger commented Feb 21, 2019

@abe33 Friendly ping, could you take a look at this?

@lgeiger
Copy link
Author

lgeiger commented Nov 5, 2019

Any updates on this?

@aminya
Copy link

aminya commented Nov 22, 2020

🎉 This PR is included in version 0.11.0 of atom-utils-plus 🎉

The release is available on:

Your semantic-release bot 📦🚀

aminya pushed a commit to lgeiger/minimap that referenced this pull request Nov 22, 2020
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.
aminya added a commit to lgeiger/minimap that referenced this pull request Nov 22, 2020
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.
aminya added a commit to lgeiger/minimap that referenced this pull request Nov 22, 2020
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants