1.0.0 • Published 3 years ago

mm-scroll v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

Features

This package provides features like infinite scrolling and lazy loading.

Components

  • RNInfiniteScroll
  • RNImageText

To use any of the provided Components, install this package as below:

Install the package:

npm install --save @rnaccelerators/infinite-scroll

InfiniteScroll

Import the InfiniteScroll component:

import {RNInfiniteScroll} from '@rnaccelerators/infinite-scroll'

Usage:

 <RNInfiniteScroll
    style={style}
    itemList={data}
    keyExtractor={keyExtractor}
    onEndReached={onEndReached}
    onEndReachedThreshold={onEndReachedThreshold}
    ListFooterComponent={ListFooterComponent}
    removeClippedSubviews={removeClippedSubviews}
    initialNumToRender={initialNumToRender}
    maxToRenderPerBatch={maxToRenderPerBatch}
    updateCellsBatchingPeriod={updateCellsBatchingPeriod}
    windowSize={windowSize}
    showsVerticalScrollIndicator={showsVerticalScrollIndicator}
    renderItem={renderItem}
    refreshing={refreshing}
    onRefresh={onRefresh}
/>

API

PropTypeRequiredDescription
stylestyleYesStyles for Flatlist.
itemListArrayYesSource of elements for the list.
renderItemFunctionYesTakes an item from the data array and maps it to a React Element.
keyExtractorStringNoUsed to extract a unique key for a given item at the specified index.
onEndReachedFunctionYesCalled when the scroll position gets within onEndReachedThreshold.
onEndReachedThresholdNumberNoHow far from the end the bottom edge of the list must be from the end of the content to trigger the onEndReached callback.
ListFooterComponentFunctionNoRendered at the very end of the list.
removeClippedSubviewsBooleanNoUnmount components when outside of window.
initialNumToRenderNumberNoNumber of items to render in the initial batch.
maxToRenderPerBatchNumberNoControls the amount of items rendered per batch.
updateCellsBatchingPeriodNumberNoadjuts the time between each batch in ms.
windowSizeNumberNoNumber of items rendered outside of the visible area.
showsVerticalScrollIndicatorBooleanNoEnable/disable the ScrollIndicator.
refreshingBooleanNoWhether the view should be indicating an active refresh.
onRefreshFunctionNoCalled when the view starts refreshing.

RNImageText

Import the RNImageText component:

import {RNImageText} from '@rnaccelerators/infinite-scroll'

Usage:

 <RNImageText
    title={title}
    id={id}
    url={url}
    onLoadStart={onLoadStart}
    onLoadEnd={onLoadEnd}
    styleCell={styleCell}
    styleImageView={styleImageView}
    styleImage={styleImage}
    styleDescription={styleDescription}
    styleName={styleName}
    styleRole={styleRole}
/>

API

PropTypeRequiredDescription
titleTextNoText for Text Component.
idTextNoText for Text Component.
urlURLYesurl for image.
onLoadStartFunctionNoInvoked on load start.
onLoadEndFunctionNoInvoked when load either succeeds or fails.
styleCellStyleYesStyle for Cell which contains Image and Text.
styleImageViewStyleYesStyle for View which contains Image.
styleImageStyleYesStyle for Image.
styleDescriptionStyleNoStyle for View which contains Name and Role.
styleNameStyleNoStyle for Name Text.
styleRoleStyleNoStyle for Role Text.