Skip to content
This repository has been archived by the owner on Mar 19, 2018. It is now read-only.

bikeshed: mayCancel is a confusing name for some use cases #13

Closed
ojanvafai opened this issue Jul 5, 2015 · 4 comments
Closed

bikeshed: mayCancel is a confusing name for some use cases #13

ojanvafai opened this issue Jul 5, 2015 · 4 comments

Comments

@ojanvafai
Copy link
Member

mayCancel makes total sense with respect to preventDefault, but it also affects whether the event is async with respect to the default action, right?

Here's an example where this name is confusing: a popup that you want to go away before the scroll starts. You still want the scroll to happen, but you don't want the popup to scroll with the content, you want it to just go away on touchstart. I can imagine as a developer being in this situation and trying to figure out if there's a way to get the event to be synchronous. "mayCancel" would not seem likely as a way to fix this.

How about "requiresSync"? or "mayBeAsync"? I don't love those names, but they're a bit more accurate and they're the best I can come up with at the moment. :)

@RByers
Copy link
Member

RByers commented Jul 6, 2015

Interesting scenario, thanks. I agree there's an opportunity for confusion here.

However I'm worried that the confusion around async/sync events means that using that term here would only further confuse the situation. In particular, my understanding of the definition of "async DOM events" is that it reflects only the ordering of what's observable to JavaScript (events, DOM changes, etc.). So touch and wheel events dispatched to mayCancel=false handlers would still be "synchronous" (the ordering of everything on the main thread remains the same). In particular, I believe it's important that hit-testing be unaffected by this #6.

Filed #14 for a specific alternative I previously rejected.

Or maybe we can do something to help avoid confusion by just adding a note? Eg.

Such an optimization would mean that the user may see the result of scrolling before the application's JavaScript has had a chance to run. In rare situations a handler may wish to modify the page before scrolling starts and so use mayCancel=true to block scrolling even though it will not actually call preventDefault.

@RByers
Copy link
Member

RByers commented Sep 22, 2015

I ended up with a very simple note, but perhaps I should add something like the above to help with this potential confusion? @annevk WDYT?

@annevk
Copy link
Collaborator

annevk commented Sep 22, 2015

I don't see how that note can be true given #20.

@RByers
Copy link
Member

RByers commented Dec 17, 2015

Name is now passive, hopefully that's good enough.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants