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
up until now it works like a charm , but there is a critical improvement it needs I have found no way of achieving : How to set a default scroll to each of the elements at load, for example I would want to set the default weight for 80kg (which is the "default" weight instead of 30 which corresponds to 0% scrolling) or if the user filled his weight and went to another part of the registration form and went back to edit it
Is there a way to scroll manually the elements with the useScroll hook , is this a react matter or a Framer Motion matter or both ?
here is my code :
constsavedValueOrDefault=80//default value or what I'd pull from saved stateconstsavedValueOrDefualt2=170//default value or what I'd pull from saved stateconst[selectedWeight,setSelectedWeight]=useState<number>(savedValueOrDefault)const[selectedHeight,setSelectedHeight]=useState<number>(savedValueOrDefualt2)constweightScrollRef=useRef(null)constheightScrollRef=useRef(null)const{scrollXProgress: weightScrollProgress}=useScroll({container: weightScrollRef})const{scrollXProgress: heightScrollProgress}=useScroll({container: heightScrollRef})constweightScale=useTransform(weightScrollProgress,value=>Math.ceil(30+(300-30)*value))constheightScale=useTransform(heightScrollProgress,value=>Math.ceil(100+(250-100)*value))weightScale.onChange(value=>{setSelectedWeight(value)})heightScale.onChange(value=>{setSelectedHeight(value)})
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello everyone,
I'm trying to make a scroll selector in my app for weight and height that works like this :
Simulator.Screen.Recording.-.iPhone.13.Pro.-.2022-07-29.at.02.18.06.mp4
up until now it works like a charm , but there is a critical improvement it needs I have found no way of achieving : How to set a default scroll to each of the elements at load, for example I would want to set the default weight for 80kg (which is the "default" weight instead of 30 which corresponds to 0% scrolling) or if the user filled his weight and went to another part of the registration form and went back to edit it
Is there a way to scroll manually the elements with the useScroll hook , is this a react matter or a Framer Motion matter or both ?
here is my code :
Beta Was this translation helpful? Give feedback.
All reactions