Skip to content

Add possibility to pass options to addEventListener#3

Open
lgeiger wants to merge 1 commit intoabe33:masterfrom
lgeiger:event-listener-options
Open

Add possibility to pass options to addEventListener#3
lgeiger wants to merge 1 commit intoabe33:masterfrom
lgeiger:event-listener-options

Conversation

@lgeiger
Copy link
Copy Markdown

@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

unless eventsForObject[event]?
eventsForObject[event] = {}
disposablesForObject[event] = @createEventListener(object, event)
disposablesForObject[event] = @createEventListener(object, event, options)
Copy link
Copy Markdown
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
Copy Markdown
Author

lgeiger commented Feb 15, 2019

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

@lgeiger
Copy link
Copy Markdown
Author

lgeiger commented Feb 21, 2019

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

@lgeiger
Copy link
Copy Markdown
Author

lgeiger commented Nov 5, 2019

Any updates on this?

@aminya
Copy link
Copy Markdown

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