[pointerevents] Implement penover / pendown / penmove / penup events and similar for other new pointer types. (#359)

flackr has just created a new issue for https://github.com/w3c/pointerevents:

== Implement penover / pendown / penmove / penup events and similar for other new pointer types. ==
#203 proposes being able to assign different touch-action values by pointer type, however I think that the idea of telling the browser not to handle pen inputs, and adding a passive pointerevent listener to filter on pen events is a bit inefficient and also not as ergonomic as directly expressing what you want, which is to handle (and block) pen events.

I propose that we allow developers to instead add a pendown listener which will be called when PointerEvent events of type 'pointerdown' and pointerType 'pen' are generated. I think that this more directly expresses the developer intent to handle pen events, allows the browser to continue to accelerate touch scrolls, and is more efficient in that we don't even have to send the touch events to blink.

TLDR; the rough proposal here is when a pointer* event `e` of pointerType 'pen' occurs, we would:
First dispatch pointer* listeners with `e`.
Then dispatch pen* listeners with `e` (possibly only if e hadn't prevented).

e.g.
```js
elem.addEventListener('pendown', (evt) => {
  console.log('pendown');
});
elem.addEventListener('pointerdown', (evt) => {
  console.log('pointerdown');
});
```
Touching elem with the pointer would result in the following output:
```
pointerdown
pendown
```

This matches the order and roughly the [behavior with legacy events](https://jsfiddle.net/flackr/34Lvkrq8/6/) except that with legacy events we are not consistent about whether preventing the event in the pointer* listener prevents the dispatch of the type specific listener, and we would be invoking the listener with the generic PointerEvent event rather than adding a new PenEvent type.

Please view or discuss this issue at https://github.com/w3c/pointerevents/issues/359 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 14 April 2021 19:02:00 UTC