react-native-auto-scroll-view
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

react-native-auto-scroll-view

ScrollView component that disables vertical scrolling if ScrollView content takes less space than ScrollView wrapper and enables vertical scrolling if ScrollView content takes more space than ScrollView wrapper.

Installation

yarn add react-native-auto-scroll-view

Example

import { Text } from 'react-native';
import AutoScrollView from 'react-native-auto-scroll-view';

const TestComponent = () => {
  // in this case, scrolling will be enabled
  // if decrease size of the array from 20 to 5 for example, scrolling will be disabled
  const testArray = new Array(20).fill('lorem ipsum');
  const styles = {
    contentContainerStyle: {
      flexGrow: 1,
    },
    text: {
      backgroundColor: 'pink',
      padding: 20,
      marginVertical: 5,
    },
  };

  return (
    <AutoScrollView
      contentContainerStyle={styles.contentContainerStyle}
    >
      {testArray.map((element, index) => (
        <Text key={index} style={styles.text}>{element}</Text>
      ))}
    </AutoScrollView>
  );
};

You can use all default ScrollView properties and methods: Docs of ScrollView

Readme

Keywords

none

Package Sidebar

Install

npm i react-native-auto-scroll-view

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

3.91 kB

Total Files

4

Last publish

Collaborators

  • zaporozhets