npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-autoscroll-flatlist

v1.11.2

Published

An enhanced React Native FlatList component to provide auto-scrolling functionality

Downloads

2,206

Readme

react-native-autoscroll-flatlist

react-native-autoscroll-flatlist is released under the MIT license. react-native-autoscroll-flatlist's current npm package version

An enhanced version of the original react-native <FlatList> component with built-in support for both Javascript and Typescript usage.

This component enables auto-scrolling on new item added to the list - which works like any chat client.

Now supports horizontal <FlatList> as well in version >= 1.6.0.

Demo

demo

Features

Auto-scroll is disabled when scrolled away from end of list. There are 3 ways to re-enable auto-scrolling:

  • You can manually scroll back to the end of list.

scroll to end manually

  • You can tap on the scrollToEndIndicator (customizable) shown on the bottom right of the list.

scroll to end by tapping on scrollToEndIndicator

  • You can tap on the newMessageAlertComponent (customizable) shown on the top of the list.

scroll to end by tapping on newMessageAlert

  • Inverted FlatList is also supported by passing the boolean inverted to the props.

inverted support

  • Horizontal (landscape) orientation is supported by passing the boolean horizontal to the props.

horizontal support

horizontal-inverted support

Installation

npm install --save react-native-autoscroll-flatlist

or

yarn add react-native-autoscroll-flatlist

Example Usage

Import the component with:

import {AutoScrollFlatList} from "react-native-autoscroll-flatlist";

and simply use it like an ordinary <FlatList>, for example:

<AutoScrollFlatList
    ref={this.myRef}
    threshold={20}
    data={myData}
    renderItem={({item, index}) => <YourComponent item={item} index={index} />}
    keyExtractor={item => item.id}
/>

You can check out the example folder for further details.

You can check out App.tsx, or replace it with the content of App-Horizontal.tsx to try out usage in landscape orientation.

Note that the landscape demo does not work in react-native-web because of the constraint with ScreenOrientation not being able to lock it to horizontal.

Properties

This component extends the official FlatListProps with the following additional props:

You can read the type definitions file for more details and explanations.

Methods

This component extends the official FlatList Methods with the following modified / additional methods:

| Method | Parameters | Description | | --------------- | ---------------------------------------------- | ------------------------------------------------------------------------- | | scrollToEnd | params: {animated: boolean} = {animated: true} | Set newItemCount to 0 and then trigger scrollToOffset to end of page. | | isAutoScrolling | | Returns whether auto-scrolling (boolean) is in effect. |

FAQ for usage on react-native-web

There are certain caveats for usage on react-native-web:

Q: My page keeps expanding in height and the autoscroll function is not being triggered. How do I fix this?

A: For usage in react-native, usually add a flex property such as flex: 1 to the container would be sufficient to get FlatList working. However, when it comes to react-native-web, you will have to explicitly set the height of the container such that it will not keep expanding. To do so, a simple fix would be to add

height: Dimensions.get("window").height
maxHeight: Dimensions.get("window").height

to the container style (depending on your use cases).