Skip to content

Instantly share code, notes, and snippets.

@malerba118
Last active August 26, 2022 22:27
Show Gist options
  • Save malerba118/c0f76c62f416feb9cd3d5e69f69fba1d to your computer and use it in GitHub Desktop.
Save malerba118/c0f76c62f416feb9cd3d5e69f69fba1d to your computer and use it in GitHub Desktop.
import { useScroll } from 'framer-motion';
const Navbar = () => {
const scroll = useScroll();
const [timeRemaining, setTimeRemaining] = React.useState(readTime);
React.useEffect(() => {
return scroll.scrollYProgress.onChange((progress) => {
setTimeRemaining(Math.floor(readTime * (1 - progress)));
});
}, []);
return <div>{/* ... */}</div>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment