Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatible with useGesture’s useWheel event handler #5

Closed
wolfgangschoeffel opened this issue Jan 3, 2024 · 2 comments
Closed

Comments

@wolfgangschoeffel
Copy link

Describe the bug
When passing the event from useGesture’s wheel gesture, I get this error:

Uncaught Error: No event provided

To Reproduce
Steps to reproduce the behavior:
Implement basic wheel gesture like in this example:
https://codesandbox.io/p/sandbox/lethargy-2coe8?file=%2Fsrc%2Findex.js%3A22%2C41

Expected behavior
lethargy.check(event) is expected to return -1 or 1 but instead the above mentioned error is thrown.

Screenshots
Screenshot 2024-01-03 at 20 18 06

@snelsi
Copy link
Owner

snelsi commented May 4, 2024

Lethargy.check function expects you to pass an instance of Event to it.
Otherwise it will throw an error.

Looks like @use-gesture library you're using returns an instance of SyntheticEvent, which is a custom React wrapper for native Events. That's why you're seeing this error message.

I'll add a check for this use-case in the next release, but for now you can quickly fix this on your side by passing event.nativeEvent like this:

const bind = useWheel(({ event }) => {
-  const isHuman = lethargy.check(event)
+  const isHuman = lethargy.check(event.nativeEvent)

@snelsi snelsi closed this as completed May 15, 2024
@wolfgangschoeffel
Copy link
Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants