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

Event listener options #1408

Open
tigt opened this issue Aug 30, 2019 · 0 comments
Open

Event listener options #1408

tigt opened this issue Aug 30, 2019 · 0 comments

Comments

@tigt
Copy link
Contributor

tigt commented Aug 30, 2019

Description

It’s a shame that to use all the features of browser event handlers, one has to drop out of the happy path syntax and manually initialize/clean up listeners in the class — especially if the component would not be stateful otherwise.

Why

  • passive: true is crucial for smooth scrolling for pages with touch*/wheel handlers — see Default touch/wheel events to passive #1404
  • Sometimes, the capturing phase of events is necessary (especially with focus-ish events)
  • Marko already has the once option with once-eventName, so that’s cool

It also seems likely that addEventListener() will gain more options as the Web platform advances.

Possible Implementation & Open Questions

The first thing that jumped to my mind was a second argument to event attributes:

<button on-click=(handler, { …options })>

But I can see how the wrapping parentheses are undesirable. It could also look like this with a handler prop, which surprisingly has precedent on the Web platform:

<button on-click={ handler: handlerFn, passive: true, once: true }>

Is this something you're interested in working on?

Yes

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

No branches or pull requests

1 participant