xcarpentier / rn-tourguide

🚩Make an interactive step by step tour guide for your react-native app (a rewrite of react-native-copilot)
https://xcarpentier.github.io/rn-tourguide/
Other
711 stars 212 forks source link

Scroll to step off screen #113

Open LaikaTheSpaceDog opened 1 year ago

LaikaTheSpaceDog commented 1 year ago

Is it possible on step change to scroll to a specific item in ScrollView? We are using rn-tourguide in our app, however as the app has grown some of the items in our onboarding are no longer visible on initial load without scrolling down, especially on smaller screens.

imamrobani commented 11 months ago

Is it possible on step change to scroll to a specific item in ScrollView? We are using rn-tourguide in our app, however as the app has grown some of the items in our onboarding are no longer visible on initial load without scrolling down, especially on smaller screens.

same here, need solution

nurikon commented 10 months ago

===>>> pass ref to scrollview const scrollViewRef = useRef(null);

===>>> get use eventEmitter const { canStart, start, eventEmitter } = useTourGuideController() useEffect(() => { eventEmitter.on('stepChange', handleOnStepChange) }, []) ===>>> manage to scrolling by steps const handleOnStepChange = (step: any) => { if (step && step.order === 7 && scrollViewRef.current) { scrollViewRef.current.scrollToEnd({ animated: true }); } else if (step && step.order === 6 && scrollViewRef.current) { scrollViewRef.current.scrollTo({ y: _w(45), animated: true }); } else { scrollViewRef.current.scrollTo({ y: -1000, animated: true }); } }
anniewey commented 9 months ago

===>>> pass ref to scrollview const scrollViewRef = useRef(null);

===>>> get use eventEmitter const { canStart, start, eventEmitter } = useTourGuideController()

useEffect(() => { eventEmitter.on('stepChange', handleOnStepChange) }, [])

===>>> manage to scrolling by steps

const handleOnStepChange = (step: any) => { if (step && step.order === 7 && scrollViewRef.current) { scrollViewRef.current.scrollToEnd({ animated: true }); } else if (step && step.order === 6 && scrollViewRef.current) { scrollViewRef.current.scrollTo({ y: _w(45), animated: true }); } else { scrollViewRef.current.scrollTo({ y: -1000, animated: true }); } }

Tried this approach but the highlighted button position is not updated to after scroll position. Need to break to multiple tour