2.0.4 • Published 8 years ago

react-limited-infinite-scroll v2.0.4

Weekly downloads
5
License
MIT
Repository
github
Last release
8 years ago

中文 README

Limited Infinite Scroll

React infinite scroll loader component, mannual loader will replace auto-loader when the page reach the limit(Because some users do not like infinite loading all pages, maybe they just want to see the footer)

Demo

Installation

npm install react-limited-infinite-scroll --save-dev

Usage

import LimitedInfiniteScroll from 'react-limited-infinite-scroll'

const { total, list } = this.props.data

const items = list.map((item, index) => {
    return (
        <div key={index}>
            <div>item content</div>
        </div>
    )
})

<LimitedInfiniteScroll 
    limit={5} 
    hasMore={total === undefined || items.length < total}
    spinLoader={<div className="loader">Loading...</div>}
    mannualLoader={<span style={{fontSize: 20, lineHeight: 1.5, marginTop: 20, marginBottom: 20, display: 'inline-block'}}>Load More</span>}
    noMore={<div className="loader">No More Items</div>} 
    loadNext={this.loadNextFunc}>
    {items}
</LimitedInfiniteScroll>

Props

NameTypeDefaultDescription
limitNumber10a load more button will replace auto-loader when pages reach the limit
pageStartNumber0start page number
thresholdNumber200The distance in pixels before the end of the items that will trigger a call to loadNext
hasMoreBooleanfalseWhether there are more items to be loaded
autoLoadBooleantrueWhether the component should load the first set of items
useWindowBooleantrueAdd scroll listeners to the window, or else, the component's parentNode
loadNextFunctionA callback for loading next set of items
spinLoaderElementauto loading indicator
mannualLoaderElementmannual load-more button
noMoreElementnullindicator for no more items

Others

For React 15.5+ users, install v2.x.x

npm install react-limited-infinite-scroll --save-dev

or install v1.x.x

npm install react-limited-infinite-scroll@~1.0.0 --save-dev
2.0.4

8 years ago

1.0.3

8 years ago

2.0.3

8 years ago

2.0.2

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago