-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Adding useViewportScroll
#7
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
Conversation
src/hooks/use-viewport-scroll.ts
Outdated
| y.set(window.pageYOffset) | ||
| } | ||
|
|
||
| window.addEventListener("scroll", onScroll, { passive: true }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could use the useEvent hook
src/hooks/use-viewport-scroll.ts
Outdated
| useEffect(() => { | ||
| const onScroll = () => { | ||
| x.set(window.pageXOffset) | ||
| y.set(window.pageYOffset) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a cross browser value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah nowadays this is fine https://developer.mozilla.org/en-US/docs/Web/API/Window/pageXOffset
src/hooks/use-transform.ts
Outdated
| transformer: interpolate(from, to), | ||
| }) | ||
|
|
||
| const transformer = interpolate(from, to) as Transformer<any> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this need casting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It used to moan, now it doesn't for some reason!
Uh oh!
There was an error while loading. Please reload this page.