servo / servo/servo

click event should not be dispatched if mouseforcewillbegin is prevented.

Open
#11,664 0 comments 0 reactions 1 assignee View on GitHub

@paulrouget is already working on this.

Since Jun 8, 2016.

A-content/dom
Dominant language
Rust
Stars
38k
Forks
3.8k
Avg merge
1d 6h
Merged PRs (30d)
465

Description

It is not documented clearly on https://developer.apple.com/library/mac/documentation/AppleApplications/Conceptual/SafariJSProgTopics/RespondingtoForceTouchEventsfromJavaScript.html, but with force touch API you can prevent click events from dispatching if you decide to handle force touch by calling event.preventDefault() at mouseforcewillbegin, which is pretty important otherwise user needs to communicate intend that force touch is being handled instead of click with in the application on it's own, which can be little tricky due to the fact that event propagation and the fact that force maybe handled on one layer while click it the other.

Here is an example I've put together

https://output.jsbin.com/mosodu

I if you try it on safari / webkit you'll notice that circle never becomes purple, neither isClicked becomes true unless you release while isForceBegan: false / circle is yellow.

On servo though you'll notice different behavior:

  1. isForceBegan is never true, presumably because servomouseforcewillbegin is never dispatched, while it supposed to right before mousedown.
  2. isClicked becomes true regardless of when you release.
  3. There are also some rendering issues, although that's not really related to this issue.

I suspect servomouseforcewillbegin was never implemented, which makes it impossible to cancel click events regardless if we handle force touch events or not.

I would expect servomouseforcewillbegin to be dispatched, before mousedown event & calling event.preventDefault() to prevent click event from being dispatched unless mouseup is dispatched before servomouseforcedown is.

P.S. You're supposed to click / touch the circle to observe force applied etc...

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.