Coder Social home page Coder Social logo

khadorkin / react-native-bidirectional-infinite-scroll Goto Github PK

View Code? Open in Web Editor NEW

This project forked from getstream/react-native-bidirectional-infinite-scroll

0.0 1.0 0.0 714 KB

๐Ÿ“œ React Native - Bidirectional Infinite Smooth Scroll

License: MIT License

JavaScript 5.72% Java 25.38% TypeScript 52.75% C 0.41% Objective-C 13.03% Swift 0.32% Ruby 2.39%

react-native-bidirectional-infinite-scroll's Introduction

๐Ÿ“œ React Native Bi-directional Infinite Scroll

License Npm Package Compatibility

Implement bidirectional infinite smooth scroll using React Native

[ Built with โ™ฅ at Stream ]

Vishal - Article 01

Tutorial on how to implement Chat UI with bidirectional infinite scroll

https://dev.to/vishalnarkhede/react-native-how-to-build-bidirectional-infinite-scroll-32ph

Introduction

FlatList by react-native only allows infinite scroll in one direction (using onEndReached). This package adds capability on top of FlatList to allow infinite scroll from both directions, and also maintains smooth scroll UX.

  • Accepts prop onStartReached & onEndReached, which you can use to load more results.
  • Calls to onEndReached and onStartReached have been optimized.
  • Inline loading Indicators, which can be customized as well.
  • Uses flat-list-mvcp to maintain scroll position or smooth scroll UX.
iOS Android

๐Ÿ›  Installation

yarn add react-native-bidirectional-infinite-scroll @stream-io/flat-list-mvcp

๐Ÿ”ฎ Usage

Please check the example app for working demo.

import { FlatList } from "react-native-bidirectional-infinite-scroll";

<FlatList
    data={numbers}
    renderItem={ListItem}
    keyExtractor={(item) => item.toString()}
    onStartReached={onStartReached} // required, should return a promise
    onEndReached={onEndReached} // required, should return a promise
    showDefaultLoadingIndicators={true} // optional
    onStartReachedThreshold={10} // optional
    onEndReachedThreshold={10} // optional
    activityIndicatorColor={'black'} // optional
    HeaderLoadingIndicator={() => { /** Your loading indicator */ }} // optional
    FooterLoadingIndicator={() => { /** Your loading indicator */ }} // optional
    enableAutoscrollToTop={false} // optional | default - false
    // You can use any other prop on react-native's FlatList
/>

Note:

  • onEndReached and onStartReached only get called once, per content length.
  • onEndReached and onStartReached must return a promise.
  • maintainVisibleContentPosition is fixed, and can't be modified through props.
  • doesn't accept ListFooterComponent via prop, since it is occupied by FooterLoadingIndicator

โœ Contributing

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

๐ŸŽ— License

MIT

react-native-bidirectional-infinite-scroll's People

Contributors

vishalnarkhede avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.