question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Replace touch and mouse events with pointer events

See original GitHub issue

The library currently uses mouse and touch event bindings from V1 when IE11 was supported. All currently targeted browsers support pointer events so they should be used instead.

See https://github.com/nerdyman/react-compare-slider/commit/5c84c5c7334dd2724d12a4c6e0eba043dd6aa687 (full file here) for a reference implementation.

Requirements

  • Add touchAction: 'none' style property to root element
  • Replace mousedown event binding with pointerdown
  • Remove touchstart event binding
  • Update mouse and touch handlers to replace MouseEvent | TouchEvent with PointerEvent
  • Remove instanceof ternaries in mouse and touch handlers, we can use ev.pageX and ev.pageY

Testing

  • Test on iOS Safari
  • Test on Firefox Android
  • Test on Chrome Safari
  • Test on Android Chrome
  • Test on Desktop Safari
  • Test on Desktop Chrome
  • Test on Desktop Firefox

Notes

Some automated testing with Storybook has been set up in #65 so it’s probably worth waiting for that to be merge before starting this.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
muditchoudharycommented, Oct 11, 2022

@nerdyman If this issue requires the work of just replacing the events in the code I could do that. I’ll try to fix this issue with the help of your PR. If I will not able to do it I’ll tell you.

0reactions
nerdymancommented, Oct 10, 2022

@muditchoudhary Those events need removed/replaced with pointerup and pointermove events. I’ve updated the description for this issue to include links to the full file and also to the previously closed PR. Note that the linked PR also includes a new transition feature, that feature is not part of this ticket, just the pointer events changes listed in the description of this issue.

Here’s a link to the diff for the pointer events in that PR. The styles for the root element are in rootStyles in the main component.

The linked PR should have everything needed to check the requirements for this PR. This isn’t the simplest issue so if you’d like something else for Hacktoberfest #75 is also open.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Replacing MouseEvents with PointerEvents
Pointer Events provide all the usual properties present in Mouse Events (client coordinates, target element, button states, etc.) in addition to ...
Read more >
Pointer events - The Modern JavaScript Tutorial
Pointer events are a modern way to handle input from a variety of pointing devices, such as a mouse, a pen/stylus, a touchscreen,...
Read more >
Pointer events - Web APIs | MDN
Mouse events can only be prevented when the pointer is down. · Hovering pointers (e.g. a mouse with no buttons pressed) cannot have...
Read more >
Learn Pointer Events In 15 Minutes - YouTube
Almost everyone defaults to using mouse events such as mousedown and mouseup, but this is not ideal. Mouse events do not include things...
Read more >
Pointer Events - W3C
Any touch contact, pen stylus, mouse cursor, or other pointer that can produce events. If it is possible for a given pointer (identified...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found