Socket
Socket
Sign inDemoInstall

react-native-sortable-listview

Package Overview
Dependencies
1
Maintainers
3
Versions
20
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-native-sortable-listview

Drag drop capable wrapper of ListView for React Native


Version published
Weekly downloads
3.1K
increased by9.21%
Maintainers
3
Install size
1.21 MB
Created
Weekly downloads
 

Changelog

Source

[0.2.9] - 2019-07-28

Added

  • Adapting for web, by neutralizing LayoutAnimation (#145)

Changed

  • Use ListView from deprecated-react-native-listview (#166)

Readme

Source

react-native-sortable-listview

Drag drop capable wrapper of ListView for React Native. Allows for dragging and dropping of rows with automatic scrolling while dragging.

Add it to your project

  1. Run npm install react-native-sortable-listview --save
  2. import SortableListView from 'react-native-sortable-listview'

Demo

Basic usage

See example.

Example

See Sortable.

Props

SortableListView passes through all the standard ListView properties to ListView, except for dataSource. The renderRow method must render a component that forwards onLongPress and onPressOut methods to a Touchable* child component. Calling the onLongPress method will enable the drag and drop on the row and onPressOut will cancel it. You can also apply the default behaviour by spreading the sortHandlers prop (e.g. <TouchableHightlight {...this.props.sortHandlers} >..)

PropertyTypeDescription
onRowMovedFunctionshould return a function that is passed a single object when a row is dropped. The object contains three properties from, to, and row. from and to are the order indexes being requested to move. row is all the info available about the row being dropped.
dataObjectTakes an object.
rowHasChangedFunctionTakes an function that is called to compare row data. It is passed the new row data and a shallow copy of the previous row data. This is necessary to define if row data is not immutible for row changes to correctly propagate, if your row data is immutable DO NOT DEFINE, see #28 for reasons why.
orderArray (Optional)Expects an array of keys to determine the current order of rows.
sortRowStyleObject (Optional)Expects a style object, which is to be applied on the rows when they're being dragged.
disableSortingBoolean (Optional)When set to true, all sorting will be disabled, which will effectively make the SortableListView act like a normal ListView.
onMoveStartFunction (Optional)Register a handler to be called when drag start.
onMoveEndFunction (Optional)Register a handler to be called when move is completed.
onRowActiveFunction (Optional)Register a handler to be called when row is activated, return a object contains three properties rowData, touch and layout. rowData is the data info of activated row, layout is the layout info of the activated row, touch is the nativeEvent of long press
onMoveCancelFunction (Optional)Register a handler to be called when move is canceled, that is the row is activated on long press and then released without any move.
activeOpacityNumber (Optional)Sets opacity of an active element. Default value: 0.2.
limitScrollingBoolean (Optional)When set to true, scrolling will be disabled when a row is active (sorting). Default is false.
moveOnPressInBoolean (Optional)When set to true, longPress delay is eliminated. Default is false.
ListViewComponent_(Function) (Optional)A custom ListView component to be used instead of React-Native's ListView.
disableAnimatedScrollingBoolean (Optional)When set to true, scrolling will no longer animate. Default is false. Strongly recommend set it to true., see #97 for more context.

Methods

NameDescription
scrollTo(...args)Scrolls to a given x, y offset, either immediately or with a smooth animation. See ScrollView's scrollTo method.

Contributing

Before submitting a PR, please:

  1. Format your code by running npm run prettier.
  2. Test by running npm run test. (Currently this produces 2 warnings, no errors).
  3. Build the Sortable example app and test fully for regressions on both iOS and android.
  4. Describe your change in the Unreleased section of the Changelog.

MIT Licensed

Keywords

FAQs

Last updated on 28 Jul 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc