react-native-scrollview-offset
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

react-native-scrollview-offset

React-Native Android doesn't support contentOffset prop (see: https://github.com/facebook/react-native/issues/6849)

Use this component as a drop-in ScrollView replacement for contentOffset cross-compatibility.

To avoid jumping, this component waits with opacity:0 until after render, then calls scrollTo(props.contentOffset), then sets itself to opacity:1.

Usage:

import ScrollViewOffset from 'react-native-scrollview-offset'
 
function App() {
  return (
    <>
      <ScrollViewOffset contentOffset={{ x: 0, y: 50 }}>
        <Text>I'm in a ScrollView that loads with an intial scroll position 50 pixels down.</Text>
        <Text>Even in Android (wow!)</Text>
      </ScrollViewOffset>
    </>
  )
}

It also offers a new prop — startAtEnd (boolean, default: false) — to set the initial scroll position to the end.

Note: startAtEnd overrides the contentOffset prop.

Supports all other props from the default ScrollView.

Package Sidebar

Install

npm i react-native-scrollview-offset

Weekly Downloads

1

Version

1.0.0

License

ISC

Unpacked Size

6.93 kB

Total Files

7

Last publish

Collaborators

  • dsernst