You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trying to apply useScroll and useTransform to "pin" an element while scrolling, so that it gets transformed by the same amount that's scrolled. This works on desktop browsers, but on mobile it's jittery.
Example component:
import{motion,useScroll,useTransform}from'framer-motion';import{typePropsWithChildren,useRef}from'react';exportfunctionPinnedElement({ children }: PropsWithChildren){constref=useRef(null);const{ scrollYProgress }=useScroll({target: ref,offset: ['end end','end start'],});consty=useTransform(scrollYProgress,[0,1],['0vh','100vh']);return(<motion.divref={ref}layoutstyle={{ y }}>{children}</motion.div>);}
1. Describe the bug
Trying to apply
useScroll
anduseTransform
to "pin" an element while scrolling, so that it gets transformed by the same amount that's scrolled. This works on desktop browsers, but on mobile it's jittery.Example component:
2. CodeSandbox reproduction of the bug
Reduced test case of the issue is here: https://codesandbox.io/p/sandbox/headless-moon-9dt5n8?file=%2Fsrc%2FApp.js
and you can view the bug on your phone here: https://9dt5n8.csb.app/
4. Steps to reproduce
Steps to reproduce the behavior:
5. Expected behavior
Pinned content should be motionless / not jittery
6. Video or screenshots
If applicable, add a video or screenshots to help explain the bug.
7. Environment details
iOS 17.5.1
The text was updated successfully, but these errors were encountered: