- From: Robert Flack via GitHub <sysbot+gh@w3.org>
- Date: Wed, 14 Apr 2021 20:40:35 +0000
- To: public-pointer-events@w3.org
I agree it's not hard for developers to have a switch on pointerType, the problem is that the browser can't know that they only care to handle a certain pointer type (e.g. pen for a drawing application) so the natural way of adding a listener like the following will slow down touch scrolling as well: ```js canvas.addEventListener('pointerdown', (evt) => { if (evt.pointerType != 'pen') return; evt.preventDefault(); // Start drawing. }); ``` Without input type specific handlers, the developer has to work around this by defining a pointer type specific touch action (in the linked issue) so that the events produce no default action and ensure that the element uses a passive event listener: ```html <style> canvas { pointer-action: pen(none); } </style> <script> canvas.addEventListener('pointerdown', (evt) => { if (evt.pointerType != 'pen') return; // Start drawing. }, {passive: true}); </script> ``` However, it may be that the complexity of having additional event listener types is not worth it. -- GitHub Notification of comment by flackr Please view or discuss this issue at https://github.com/w3c/pointerevents/issues/359#issuecomment-819817400 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 20:40:38 UTC