2.4.4 • Published 3 years ago

react-native-drag-sort v2.4.4

Weekly downloads
1,303
License
ISC
Repository
github
Last release
3 years ago

react-native-drag-sort

Drag and drop sort control for react-native

GitHub license npm

Version Iteration

Installation

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

export { DragSortableView, AutoDragSortableView, AnySizeDragSortableView }

Tip

Use priority: DragSortableView > AutoDragSortableView > AnySizeDragSortableView

  • 1、If the width and height are fixed and there is no need to slide, use DragSortableView.
  • 2、If the width and height are fixed and you need to slide, use AutoDragSortableView.
  • 3、If the width and height are arbitrary and need to slide, please use AnySizeDragSortableView.

Performance(GIF)

AnyThreePageAnyThreePage
AnysizeAnysize
AutomaticSlidingOnePageAutomaticSlidingThreePage
npm.ionpm.io
ScrollFixedAddPageDragDeletePage
npm.iodragdelete.gif
SortAndFixedPageOneRowsPage
ezgif.com-resize.gifone-line.gif

API

AutoDragSortableView、DragSortableView

isRequired if there is a * in the name field

nameProptypesDescription
dataSource *array
parentWidthnumberparent width
childrenHeight *numberEach item height
childrenWidth *numberEach item width
marginChildrenTopnumberSo the item's outermost view adds margin, you can only use this method.
marginChildrenBottomnumber
marginChildrenLeftnumber
marginChildrenRightnumber
sortableboolDo not allow dragging
onClickItemfuncclick
onDragStartfunc
onDragEndfunc
onDataChangefuncThis method is called every time the data changes.
renderItem *funcrender item view
fixedItemsarrayno remove
keyExtractorfunc(item,index) => key
delayLongPressnumber
isDragFreelyboolWhether to limit the drag space
onDraggingfunc
maxScalenumber
minOpacitynumber

The following attributes belong only to AutoDragSortableView

nameProptypesDescription
scaleDurationnumber
slideDurationnumber
autoThrottlenumber
autoThrottleDurationnumber
renderHeaderViewelement
headerViewHeightnumber
scrollIndicatorInsets({top:number, left:number, bottom:number, right:number})
renderBottomViewelement
bottomViewHeightnumber
onScrollListener(event: NativeSyntheticEvent) => void
onScrollRef(ref: any) => void
AnySizeDragSortableView
nameProptypesDescription
dataSource *array
keyExtractorfunc.isRequired(item,index) => key
renderItem *funcrender item view
onDataChangefuncThis method is called every time the data changes.
renderHeaderViewelement
headerViewHeightnumber
renderBottomViewelement
bottomViewHeightnumber
autoThrottlenumber
autoThrottleDurationnumber
onDragEndfunc
scrollIndicatorInsets({top:number, left:number, bottom:number, right:number})
onScrollListener(event: NativeSyntheticEvent) => void
onScrollRef(ref: any) => void
areaOverlapRationumberMust be greater than 0.5
movedWrapStyleStylePropstyle
childMarginTopnumber
childMarginBottomnumber
childMarginLeftnumber
childMarginRightnumber

Example

<DragSortableView
    dataSource={this.state.data}
    parentWidth={parentWidth}
    childrenWidth= {childrenWidth}
    childrenHeight={childrenHeight}
    keyExtractor={(item,index)=> item.id}
    renderItem={(item,index)=>{
        return this.renderItem(item,index)
    }}
/>
    
<AutoDragSortableView
    dataSource={this.state.data}
    parentWidth={parentWidth}
    childrenWidth= {childrenWidth}
    childrenHeight={childrenHeight}
    keyExtractor={(item,index)=> item.id}
    renderItem={(item,index)=>{
        return this.renderItem(item,index)
    }}
/>

// ====== AnySizeDragSortableView start =======

constructor(props) {
    super(props);
    this.sortableViewRef = createRef()
}

<AnySizeDragSortableView
    ref={this.sortableViewRef}
    dataSource={items}
    keyExtractor={(item) => item.text} // 1、isRequired
    renderItem={this._renderItem}
    onDataChange={(data, callback)=> {
        this.setState({items: data},()=>{
            callback() // isRequired
        })
    }}
/>

_renderItem = (item, index, isMoved) => {
    return (
    	<TouchableOpacity
	        onLongPress={() => {
	            this.sortableViewRef.current.startTouch(item, index) // 2、isRequired	        }}
	        onPressOut = {() => {
	        	this.sortableViewRef.current.onPressOut() 3、isRequired
	        }}
	      >
      	<...>
      </TouchableOpacity>
    )
}


// ====== AnySizeDragSortableView end =======
2.4.4

3 years ago

2.4.3

3 years ago

2.4.1

3 years ago

2.4.0

3 years ago

2.4.2

3 years ago

2.3.9

3 years ago

2.3.8

4 years ago

2.3.7

4 years ago

2.3.6

4 years ago

2.3.5

4 years ago

2.3.4

4 years ago

2.2.3

4 years ago

2.2.4

4 years ago

2.2.2

4 years ago

2.2.1

4 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.0.4

4 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.3.6

5 years ago

1.3.5

5 years ago

1.3.4

5 years ago

1.3.3

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago