[BUG] `useViewportScroll` is not updating.
See original GitHub issue1. Read the FAQs 👇
2. Describe the bug
Give a clear and concise description of what the bug is.
scrollYProgress
from useViewportScroll
hook does not update.
3. IMPORTANT: Provide a CodeSandbox reproduction of the bug
A CodeSandbox minimal reproduction will allow us to quickly follow the reproduction steps. Without one, this bug report won’t be accepted.
4. Steps to reproduce
Steps to reproduce the behavior:
- Go to https://codesandbox.io/s/trusting-jepsen-mikfs?file=/src/App.js
- Open console
- Scroll down
- No updated
scrollYProgress
value
5. Expected behavior
scrollYProgress
updates when scroll happens.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:13
Top Results From Across the Web
Framer Motion not updating scrollYProgress - Stack Overflow
I think the reason you're not seeing updates is not because of any css. Framer seems to calculate it's state standalone from react....
Read more >Bountysource
[BUG] useViewportScroll initially not updating. ... Help and Information. Frequently Asked Questions · Bugs and Feature Requests · Fees ...
Read more >[Solved]-Framer Motion not updating scrollYProgress-Reactjs
Coding example for the question Framer Motion not updating scrollYProgress-Reactjs. ... import React from "react"; import { useViewportScroll } from ...
Read more >Upgrade guides | Framer for Developers
These will now throw a type error for TypeScript users and should be converted ... This was not a performant approach because all...
Read more >Page Transitions with React Router and Framer Motion
Framer Crash Course - From UI/UX to Frontend with No Code. DesignCourse ... React & Three.js | Working with Shaders using React Three...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I ran into this couple of days ago and the issue stems from the fact that I had set the height to 100vh/100%. Try running the following snippet in your browser:
document.body.clientHeight - window.innerHeight <= 0
. If it returns true you’re probably running into the same issue and will need to use min-height rather than a fixed height for the body element.The scroll progress happens outside of the react render loop (I believe it is for performance reasons), so you actually need something like this:
I tweaked your demo code example.
I might be misunderstanding the issue though.
From the docs: