Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-drag-sort

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-drag-sort

Drag and drop sort control for react-native

  • 2.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.3K
decreased by-53.07%
Maintainers
1
Weekly downloads
 
Created
Source

react-native-drag-sort

Drag and drop sort control for react-native

GitHub license npm

Language

Installation

yarn add react-native-drag-sort
or
npm i react-native-drag-sort --save 

export { DragSortableView, AutoDragSortableView }

important hint

  1. Download Android example
  2. You must write the attribute keyExtractor = {(item, index) => item.id} id is the unique identification of your data, there is no index to replace item.id.
  3. If Android Debug mode is compared to the card. Please package and install and test, release will not get stuck. Or test animation is very smooth under iOS.
2020.2 Removed componentWillReceiveProps / componentWillMount method

Using Fiber after React 16.3, React rendering has become asynchronous rendering. For details, please Google React Fiber.

React <16.3 Please quote react-native-drag-sort@2.0.1 React> 16.3 Please quote react-native-drag-sort @ latest

Update Progress

2020.1 Added auto swipe function
If you do not need the auto-sliding function to use or are not satisfied with the Android effect, you can temporarily use DragSortableView (stable, reliable, long-term no-issus bug), if you want to use auto-sliding please use AutoDragSortableView。
The auto slide function is complete. iOS implements smooth auto-sliding. Android implements sliding an Item at a fixed time. After Android calls scrollTo, the refresh is relatively slow, causing jitter, so using a fixed time to slide 1 Item, this compromise method. You can also pass parameters: autoThrottle (sliding distance per unit time), autoThrottleDuration (time to slide a distance regularly)。
  1. It is recommended to use Demo settings: Android automatically slides an item height every 400ms, and iOS automatically slides 2 every 10ms.
  2. If you want to achieve the same effect as Android and iOS, you can configure autoThrottle = {2}, autoThrottleDuration = {10}
  3. There will be time to optimize in the later period: trigger sliding condition optimization, Android jitter optimization when sliding.

AutomaticSlidingOnePage

AutomaticSlidingThreePage

2019.10

Add a new scene based on user needs.

  • Add attribute (isDragFreely): Whether to limit the drag space.
  • Add property callback function (onDragging)
  • Add demo Demo: DragDeletePage

DragDeletePage

dragdelete.gif

2019.7

The 1.x version ends, the optimizations are optimized, and the problems that have occurred have been resolved. The 2.x version will be written next, and it is expected to add an auto-compatible ScrollView slide, slide delete function, and so on.

  • Fix a small problem.
  • Add a familiar keyExtractor:(item,index) => key to achieve performance optimization, similar to FlatList's keyExtractor, will not flash (repaint) when deleting Item.
  • Add the delayLongPress property: press to the time of the trigger, customize how long to start
2019.6

Added the top fixed function, you can set the start of several consecutive non-dragable functions, similar to today's headlines, this function is the same as today's headline drag and drop, you can compare

SortAndFixedPage

ezgif.com-resize.gif

2019.3

Add a single-line drag-and-drop demo. In fact, this function is consistent. This drag-and-drop plug-in is inherently adaptive. It will take time to optimize the ScrollView problem and make the control bring the ScrollView function。

OneRowsPage

one-line.gif

2019.2:

Optimize drag and drop automatically when not moving, now this plugin should have no problems. Add a real-world demo example, and there will be time to animate this example. When deleting, the item goes down to the item animation to be selected, and the item to be selected is selected. And automatically slide down the animation when sliding。

CommonSortPage

demo.gif

Performance

ScrollPage

Demonstration.gif

Example

<DragSortableView
    dataSource={this.state.data}
    parentWidth={parentWidth}
    childrenWidth= {childrenWidth}
    childrenHeight={childrenHeight}
    marginChildrenTop={marginChildrenTop}
    onDataChange = {(data)=>{
        // delete or add data to refresh
        if (data.length != this.state.data.length) {
            this.setState({
                data: data
            })
        }
    }}
    keyExtractor={(item,index)=> item.id}
    onClickItem={(data,item,index)=>{}}
    renderItem={(item,index)=>{
        return this.renderItem(item,index)
    }}/>

API

  • dataSource: PropTypes.array.isRequired :

  • parentWidth: PropTypes.number //parent width

  • childrenHeight: PropTypes.number.isRequired, //Each item height

  • childrenWidth: PropTypes.number.isRequired,//Each item width

  • marginChildrenTop: PropTypes.number, //So the item's outermost view adds margin, you can only use this method.

  • marginChildrenBottom: PropTypes.number,

  • marginChildrenLeft : PropTypes.number,

  • marginChildrenRight : PropTypes.number,

  • sortable: PropTypes.bool, //Do not allow dragging

  • onClickItem: PropTypes.func, //click

  • onDragStart: PropTypes.func,

  • onDragEnd : PropTypes.func,

  • onDataChange : PropTypes.func, //This method is called every time the data changes.

  • renderItem : PropTypes.func.isRequired, //render item view

  • fixedItems:PropTypes.array //no remove

  • keyExtractor: keyExtractor: PropTypes.func //(item,index) => key

  • delayLongPress: PropTypes.number

  • isDragFreely: PropTypes.bool, // Whether to limit the drag space

  • onDragging: PropTypes.func

  • maxScale: PropTypes.number;

  • minOpacity: PropTypes.number;

  • scaleDuration: PropTypes.number;

  • slideDuration: PropTypes.number;

  • autoThrottle: PropTypes.number;

  • autoThrottleDuration: PropTypes.number;

Keywords

FAQs

Package last updated on 12 Feb 2020

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc