0

This is my function:

const scrollToDown = () =>
positionRef.current.scrollTo({x: -100, y: -100, animated: true});

When calling this function I want my screen to be scrolled a little bit down, but instead it is being scrolled all the way to top of the screen.

Any suggestions please?

user14587589
  • 449
  • 3
  • 19
  • Does this answer your question? [React Native - how to scroll a ScrollView to a given location after navigation from another screen](https://stackoverflow.com/questions/46680890/react-native-how-to-scroll-a-scrollview-to-a-given-location-after-navigation-f) – TheRakeshPurohit Jul 23 '21 at 08:07

1 Answers1

1

You can try this

    const scrollRef = useRef();

    const onPressTouch = () => {
        scrollRef.current.scrollTo({
            y: 100,
            animated: true,
        });
    }

    <ScrollView ref={scrollRef}>
     ....
    </ScrollView>
Shivam
  • 2,147
  • 1
  • 11
  • 28