FormidableLabs / react-swipeable

React swipe event handler hook
https://commerce.nearform.com/open-source/react-swipeable
MIT License
1.99k stars 146 forks source link

trackMouse not working #334

Closed janwirth closed 7 months ago

janwirth commented 10 months ago

Describe the bug Mouse events are not registered despite trackMouse being enabled

Steps or Sandbox to reproduce

- https://codesandbox.io/s/react-swipeable-image-carousel-hben8

Expected behavior Mouse events trigger swipe

Device/Browser Chrome 117.0.5938.149 am64 MacOS 13.4 (22F2063)

sian022 commented 7 months ago

Hi @janwirth! Were you able to resolve this?

hartzis commented 7 months ago

I suspect the issue to be how you're missing spreading some props.

in your example you're only using the ref, when you should be spreading all props from useSwipeable

- const { ref } = useSwipeable({
+ const handlers = useSwipeable({
...
<div {...handlers}>

fyi please refer to the readme/docs

https://github.com/FormidableLabs/react-swipeable#api

sian022 commented 7 months ago

@hartzis solution worked! thanks!

janwirth commented 7 months ago

Not using it anymore, closing this issue. Thanks for the info @hartzis