Skip to content

jacobp100/react-native-scrollintoview

react-native-scrollintoview

Scolls a parent ScrollView to ensure the view is visible

Installation

npm install @jacobp100/react-native-scrollintoview

Usage

import ScrollIntoView from '@jacobp100/react-native-scrollintoview';

const Example = () => {
  const ref = useRef();

  const scrollIntoView = () => {
    ref.current.scrollIntoView({
      behavior: 'smooth', // set to auto to disable animation
      inset: {
        top: 20,
        right: 20,
        bottom: 20,
        left: 20,
      }, // Add a margin around view when scrolling
    });
  };

  return (
    <ScrollView>
      <ScrollIntoView ref={ref} />
    </ScrollView>
  );
};

Also exports AnimatedComponent if you need to provide animated styles.

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library

About

No description, website, or topics provided.

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

No packages published