Giter Club home page Giter Club logo

react-native-drag-sort's Introduction

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)

AnyThreePage AnyThreePage
Anysize Anysize
AutomaticSlidingOnePage AutomaticSlidingThreePage
ScrollFixedAddPage DragDeletePage
dragdelete.gif
SortAndFixedPage OneRowsPage
ezgif.com-resize.gif one-line.gif

API

AutoDragSortableView、DragSortableView

isRequired if there is a * in the name field

name Proptypes Description
dataSource * array
parentWidth number parent width
childrenHeight * number Each item height
childrenWidth * number Each item width
marginChildrenTop number So the item's outermost view adds margin, you can only use this method.
marginChildrenBottom number
marginChildrenLeft number
marginChildrenRight number
sortable bool Do not allow dragging
onClickItem func click
onDragStart func
onDragEnd func
onDataChange func This method is called every time the data changes.
renderItem * func render item view
fixedItems array no remove
keyExtractor func (item,index) => key
delayLongPress number
isDragFreely bool Whether to limit the drag space
onDragging func
maxScale number
minOpacity number

The following attributes belong only to AutoDragSortableView

name Proptypes Description
scaleDuration number
slideDuration number
autoThrottle number
autoThrottleDuration number
renderHeaderView element
headerViewHeight number
scrollIndicatorInsets ({top:number, left:number, bottom:number, right:number})
renderBottomView element
bottomViewHeight number
onScrollListener (event: NativeSyntheticEvent) => void
onScrollRef (ref: any) => void
AnySizeDragSortableView
name Proptypes Description
dataSource * array
keyExtractor func.isRequired (item,index) => key
renderItem * func render item view
onDataChange func This method is called every time the data changes.
renderHeaderView element
headerViewHeight number
renderBottomView element
bottomViewHeight number
autoThrottle number
autoThrottleDuration number
onDragEnd func
scrollIndicatorInsets ({top:number, left:number, bottom:number, right:number})
onScrollListener (event: NativeSyntheticEvent) => void
onScrollRef (ref: any) => void
areaOverlapRatio number Must be greater than 0.5
movedWrapStyle StyleProp style
childMarginTop number
childMarginBottom number
childMarginLeft number
childMarginRight number

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 =======

react-native-drag-sort's People

Contributors

apgsn avatar avertin avatar fallenner avatar mochixuan avatar sevellion avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

react-native-drag-sort's Issues

发现个问题,拖动后,每个item之间距离很大

<DragSortableView
// dataSource={menuStore.firstData}
dataSource={this.state.firstData}
parentWidth={parentWidth}

                    childrenWidth={childrenWidth}
                    childrenHeight={childrenHeight}

                    scaleStatus={'scaleY'}

                    onDragStart={(startIndex, endIndex) => {
                        this.setState({
                            scrollEnabled: false
                        })
                    }}
                    onDragEnd={(startIndex) => {
                        this.setState({
                            scrollEnabled: true
                        })
                    }}
                    onDataChange={(data) => {
                        // if (data.length != menuStore.firstData.length) {
                        //     menuStore.firstData = data;
                        //     this.setState({});
                        //     // this.setState({
                        //     //     data: data
                        //     // })
                        // }
                        this._changeMoveData(data);

                    }}
                    keyExtractor={(item, index) => item.txt} // FlatList作用一样,优化
                    onClickItem={(data, item, index) => {

                    }}
                    renderItem={(item, index) => {
                        return this.renderDeleteItem(item, index)
                    }}
                />

拖动前后产生的变化

Simulator Screen Shot - iPhone XS Max - 2019-07-29 at 16 30 44
Simulator Screen Shot - iPhone XS Max - 2019-07-29 at 16 30 56

Plans to deprecate componentWillReceiveProps & WillMount?

First of all, thank you very much for the awesome work! This is the most sophisticated one of the kind I have found.

I am using this in a project with a newer react-native version so I am seeing the orange warning box that says componentWillReceiveProps/componentWillMount has been renamed, and is not recommended for use.

I would like to know if you have any plan to refactor this recently, or if you would take PR for this? Thanks!

还是有bug.

dataSource更新的情况下, onDataChange 方法并不走.

Warning after drag action

react-native: "0.62.2",
react-native-drag-sort: "2.1.0"
Platform: IOS
Animated: useNativeDriver was not specified. This is a required option and must be explicitly set to true or false

AutoDragSortableView scrolling issue

AutoDragSortableView scrolling did not work on a page load but when scrolling items once and after that dragged item then scrolling work and scrolling takes more delay.

Change orientation

I love this package, saved my project!
I have an issue though when changing orientation on Android.
I cannot get it to work.

This is what I use to detect orientation change (this works):

Dimensions.addEventListener("change", function (dims) {
            self.setState({
                deviceWidth: dims.screen.width,
                deviceHeight: dims.screen.height
            });
        });

This is what I use on the package:

let delimiter = (this.state.deviceWidth > this.state.deviceHeight) ? 7 : 4;
<AutoDragSortableView
                        childrenWidth={this.state.deviceWidth / delimiter -  PixelRatio.getPixelSizeForLayoutSize(1.3)}
                        childrenHeight={80}
                        sortable={!this.state.deleteMode}
                        marginChildrenTop={PixelRatio.getPixelSizeForLayoutSize(1)}
                        marginChildrenLeft={PixelRatio.getPixelSizeForLayoutSize(1)}
                        parentWidth={this.state.deviceWidth}
                        dataSource={this.props.photoData[this.state.selectedObject]}
                        onDataChange={(data) => this._orderChange(data)}
                        keyExtractor={(item, index) => item.id}
                        onClickItem={(data, item, index) => { this._openGallery(index) }}
                        renderItem={this._renderListItem} />

If I open the screen vertically or horizontally it works, but if I change orientation while in screen it messes up. I tried to change a few things but I got no progress, is this not implemented or am I doing something wrong?
Thank you!

It's not working

import React,{Component} from 'react'
import {
  ActivityIndicator,
  StatusBar,
  StyleSheet,
  ScrollView,
  View,
  Image,
  Text,
  Dimensions
} from 'react-native';

const {width} = Dimensions.get('window')


import DragSortableView from 'react-native-drag-sort'

const parentWidth = width - 18
const childrenWidth = 76
const childrenHeight = 76
const marginChildrenTop = 7
const marginChildrenBottom = 0
const marginChildrenLeft = 0
const marginChildrenRight = 7

export default class DragTestScreem extends Component {

  constructor(props) {
    super(props);
   
    this.state = {
      data: ['cat', 'fish', 'beans', 'tree','child','ant','mountain'],
      scrollEnabled: false,
    }
  }


  renderItem (word, index) {
    return (
      <View style={sortStyles.itemContainer}>
        <Text>{word}</Text>
      </View>
    )
  }


  // Render any loading content that you like here
  render() {
    return (
      <View style={styles.container}>
        <ScrollView
          ref={(scrollView)=> this.scrollView = scrollView}
          scrollEnabled = {this.state.scrollEnabled}
          style={{flex: 1}}>
            <View style={sortStyles.container}>
              <DragSortableView
                dataSource={this.state.data}
                parentWidth={parentWidth}
               

                childrenWidth= {childrenWidth}
                childrenHeight={childrenHeight}

                marginChildrenTop={marginChildrenTop}
                marginChildrenBottom={marginChildrenBottom}
                marginChildrenLeft={marginChildrenLeft}
                marginChildrenRight={marginChildrenRight}

                onDragStart={(startIndex,endIndex)=>{
                    this.setState({
                        scrollEnabled: false
                    })
                }}
                onDragEnd={(startIndex)=>{
                    this.setState({
                        scrollEnabled: true
                    })
                }}
                onDataChange = {(data)=>{
                    // delete or add data to refresh
                    if (data.length != this.state.data.length) {
                        this.setState({
                            data: data
                        })
                    }
                }}
                onClickItem={(data,item,index)=>{
                  console.log('clicked')
                    // click delete
                    // if (this.state.isEnterEdit) {
                    //     const newData = [...data]
                    //     newData.splice(index,1)
                    //     this.setState({
                    //         data: newData
                    //     })
                    // }
                }}
                renderItem={(item,index)=>{
                    return this.renderItem(item,index)
                }}
              />
            </View>
          </ScrollView>
      </View>
    );
  }
}

const sortStyles = StyleSheet.create({
  container: {
    borderColor: '#000000',
    borderWidth: 4,
    padding: 10
  },
  itemContainer: {
    borderColor: '#F0F3F7',
    borderRadius: 8,
    borderWidth: 4,
    paddingHorizontal: 12,
    paddingVertical: 12,
    width: childrenWidth,
    height: childrenHeight,

    backgroundColor: '#f0ffff',
    justifyContent: 'center',
    alignItems: 'center'
  },
  word: {
    color: '#162842',
    fontSize: 15,
    fontWeight: 'bold',
  }
})

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: 'white',
    padding: 20
  },
})

It doesn't drag.

Can't run example app

This lib looks awesome, but I spent more than 2 hours trying to make it run after git cloning it and nothing.

Can you please provide instructions of how we're able to run it?

纵向拖拽bug

纵向拖拽,会导致,别替换的位置的item 消失或者或者和别的item 重叠

How to stop the event from bubbling

drag-sort Component is nested inside the ParallaxScrollView.

How to ensure that the sliding of ParallaxScrollView is not triggered when dragging internal drag components

Bug: drag and drop overlapping

Environment

React Native Environment Info:
    System:
      OS: Linux 4.15 Ubuntu 18.04.3 LTS (Bionic Beaver)
      CPU: (8) x64 Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
      Memory: 621.44 MB / 11.63 GB
      Shell: 5.4.2 - /bin/zsh
    Binaries:
      Node: 10.16.3 - ~/.nvm/versions/node/v10.16.3/bin/node
      Yarn: 1.19.0 - /usr/bin/yarn
      npm: 6.9.0 - ~/.nvm/versions/node/v10.16.3/bin/npm
    npmPackages:
      react: 16.8.3 => 16.8.3 
      react-native: 0.59.8 => 0.59.8 

What is the problem ?

image

The same problem occurs in my own app with custom data.

Support : drag while scrolling

The items that are rendered don't fit into one view, so I put the DragSortableView inside a ScrollView. However, when I drag one item, pulling it down (in order to see other items), the page doesn't scroll.

React Native Environment Info:
    System:
      OS: Linux 4.15 Ubuntu 18.04.3 LTS (Bionic Beaver)
      CPU: (8) x64 Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
      Memory: 1.06 GB / 11.63 GB
      Shell: 5.4.2 - /bin/zsh
    Binaries:
      Node: 10.16.3 - ~/.nvm/versions/node/v10.16.3/bin/node
      Yarn: 1.19.1 - /usr/bin/yarn
      npm: 6.9.0 - ~/.nvm/versions/node/v10.16.3/bin/npm
    npmPackages:
      react: 16.8.3 => 16.8.3 
      react-native: ^0.59.8 => 0.59.10
      "react-native-drag-sort": "^1.3.4",

实例

这个例子不知道怎么用,粘贴的代码,不能运行

  1. cd Example
  2. npm install
  3. react-native run-android or react-native run-ios
  4. 里面其实就一个控件,你可以自己改,也可以直接用,在里面有三个例子。

TypeError: null is not an object (evaluating '_this5.touchCurItem.ref')

hi,
thanks for the library.

Upon dragging and releasing item,

I sometimes get the following error:

TypeError: null is not an object (evaluating '_this5.touchCurItem.ref')

endTouch
    AutoDragSortableView.js:401:16
animation.start$argument_2
    AnimatedValue.js:217:29
__debouncedOnEnd
    Animation.js:56:19
onUpdate
    TimingAnimation.js:129:28
onUpdate
    [native code]:0
_callTimer
    JSTimers.js:148:15
callTimers
    JSTimers.js:399:17
callFunctionReturnFlushedQueue
    [native code]:0

Doesn't always happen,
it seems to happen when I drag and drop and item quickly.

Inverted list - like in FlatList

Would be nice to have an inverted list, I have a use case where I want to display the first element on the bottom of the screen so you can reach it easier.

Otherwise awesome library!

Thanks! 💪

How to refresh the DragSortableView?

<DragSortableView
showsHorizontalScrollIndicator={false}
showsVerticalScrollIndicator={false}
bounces={false}
extraData={this.state.refresh}
sortable={false}
dataSource={this.state.appList}
parentWidth={parentWidth}
childrenWidth={parentWidth}
childrenHeight={childrenHeight}
marginChildrenTop={marginChildrenTop}
marginChildrenBottom={marginChildrenBottom}
onClickItem={(data, item, index) => { this._onPressItem(item) }}
renderItem={(item, index) =>
    <View style={{ width: parentWidth, height: childrenHeight }}>
       <AppListItemView
             data={item}
             index={index}
       />
    </View>
}
/>

Then I add
this.setState({ refresh: !this.state.refresh });
into some button click.

Nothing happen.

Prefer props over library globals

The library defines a few globals including maxScale, minOpacity, scaleDuration and slideDuration.

It would be nice if the user could alter these values (e.g., setting maxScale to 1 to disable item scaling).

Please consider merging in MR #45 which removes such globals and replaces them with props with the same defaults. Since all these props are optional and their default values match the ones assigned to the globals we can guarantee backwards compatibility (thus the minor version bump).

Invariant Violation

I just updated to the latest build and I now get this error when trying to load the component. I haven't changed anything within the class...just updated the component. I've cleaned and rebuilt the app (this is on ios btw).

The error is:

2020-03-09 16:47:24.435 [error][tid:com.facebook.react.JavaScript] Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

Check the render method of `Context.Consumer`.

This error is located at:
    in RCTScrollContentView (at ScrollView.js:1038)
    in RCTScrollView (at ScrollView.js:1178)
    in ScrollView (at KeyboardAwareHOC.js:517)
    in KeyboardAwareScrollView (at Content.js:66)
    in Content (at connectStyle.js:392)
    in Styled(Content) (at Pictures/index.tsx:130)
    in Pictures (created by Context.Consumer)
    in withNavigation(Pictures) (at PicturesScreen.tsx:40)
    in RCTView (at Container.js:12)
    in Container (at connectStyle.js:392)
    in Styled(Container) (at PicturesScreen.tsx:35)
    in PicturesScreen (created by SceneView)
    in SceneView (at StackViewLayout.tsx:900)
    in RCTView (at createAnimatedComponent.js:151)
    in AnimatedComponent (at StackViewCard.tsx:106)
    in RCTView (at createAnimatedComponent.js:151)
    in AnimatedComponent (at screens.native.js:101)
    in Screen (at StackViewCard.tsx:93)
    in Card (at createPointerEventsContainer.tsx:95)
    in Container (at StackViewLayout.tsx:975)
    in RCTView (at screens.native.js:132)
    in ScreenContainer (at StackViewLayout.tsx:384)
    in RCTView (at createAnimatedComponent.js:151)
    in AnimatedComponent (at StackViewLayout.tsx:374)
    in PanGestureHandler (at StackViewLayout.tsx:367)
    in StackViewLayout (created by withOrientation)
    in withOrientation (at StackView.tsx:104)
    in RCTView (at Transitioner.tsx:267)
    in Transitioner (at StackView.tsx:41)
    in StackView (created by Navigator)
    in Navigator (created by KeyboardAwareNavigator)
    in KeyboardAwareNavigator (created by SceneView)
    in SceneView (created by TabNavigationView)
    in RCTView (created by ResourceSavingScene)
    in RCTView (created by ResourceSavingScene)
    in ResourceSavingScene (created by TabNavigationView)
    in RCTView (at screens.native.js:132)
    in ScreenContainer (created by TabNavigationView)
    in RCTView (created by TabNavigationView)
    in TabNavigationView (created by NavigationView)
    in NavigationView (created by Navigator)
    in Navigator (created by SceneView)
    in SceneView (created by SwitchView)
    in SwitchView (created by Navigator)
    in Navigator (created by NavigationContainer)
    in NavigationContainer (at App.tsx:215)
    in RCTView (created by MenuProvider)
    in RCTView (created by MenuProvider)
    in MenuProvider (at App.tsx:206)
    in StyleProvider (at App.tsx:205)
    in RCTView (at Root.js:14)
    in Root (at connectStyle.js:392)
    in Styled(Root) (at App.tsx:204)
    in App (at renderApplication.js:40)
    in RCTView (at AppContainer.js:101)
    in RCTView (at AppContainer.js:119)
    in AppContainer (at renderApplication.js:39)
2020-03-09 16:47:24.446 [error][tid:com.facebook.react.JavaScript] Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

Check the render method of `Context.Consumer`.

This error is located at:
    in NavigationContainer (at App.tsx:215)
    in RCTView (created by MenuProvider)
    in RCTView (created by MenuProvider)
    in MenuProvider (at App.tsx:206)
    in StyleProvider (at App.tsx:205)
    in RCTView (at Root.js:14)
    in Root (at connectStyle.js:392)
    in Styled(Root) (at App.tsx:204)
    in App (at renderApplication.js:40)
    in RCTView (at AppContainer.js:101)
    in RCTView (at AppContainer.js:119)
    in AppContainer (at renderApplication.js:39)

The code that I use to call it is:

<DragSortableView
    dataSource={subscriptionContext && subscriptionContext.transactionReceipt ? this.state.pictures.sort((a, b) => a.order > b.order ? 1 : -1) : this.state.pictures.sort((a, b) => a.order > b.order ? 1 : -1).slice(0, 4)}
    parentWidth={parentWidth}

    childrenWidth={childrenWidth}
    childrenHeight={childrenHeight}
    marginChildrenTop={marginChildrenTop}
    marginChildrenBottom={marginChildrenBottom}
    marginChildrenLeft={marginChildrenLeft}
    marginChildrenRight={marginChildrenRight}

    onDragStart={(fromIndex) => { // I changed this from (startIndex,endIndex) to (fromIndex)
      if (!this.state.isEditState) {
        this.setState({ isEditState: true, scrollEnabled: false });
      } else {
        this.setState({ scrollEnabled: false });
      }
    }}
    onDragEnd={(startIndex) => {
      this.setState({
        scrollEnabled: true
      })
    }}
    onDataChange={(pictures) => {
      // delete or add data to refresh
      for (var i = 0; i < pictures.length; i++) {
        if (pictures[i].order !== i) {
          pictures[i].order = i;
          // Update firebase
          if (i === 0) {
            // Set the profile picture
            value.changeProfilePicture(pictures[i])
          }
          firebase
            .database()
            .ref(`/images/${this.props.userId}/${pictures[i].id}`)
            .update({
              profile: (i === 0),
              order: i
            })
            .then()
            .catch();

        }
      }
      this.setState({
        pictures
      })
    }}
    onClickItem={(data, item, index) => {
      if (this.state.isEditState) {
        // Confirm/Delete
        this.deletePicture(data[index].id);
      } else {
        this.setState({ showPictureGallery: true, initialPage: index })
      }
    }}
    keyExtractor={(item, index) => item.id}
    renderItem={(item, index) => { return this.renderItem(item, index) }} />

Any thoughts???? I couldn't see anything within the instructions that would indicate that the code needed to change.

谢谢

Thank you @mochixuan ! react-native-drag-sort is GREAT!

-- Steven Black from 🇨🇦

dragging simultaneously with scrollview

Hi, Since I found your module useful for everyone, I think it will be awesome if we can drag simultaneously with scrollview. I can show you what I think below (I made it with movie editing tools) :
Android-Emulator-Nexus_One_API_23_5554-2019-11-07-13-14-22_2
And this feature isn't there yet:
Android-Emulator-Nexus_One_API_23_5554-2019-11-07-13-14-22

Thanks for the hard works

support different children item size

Hi, I really like this module due to high quality of implementation and I thought it would be good if working with different children item size was supported. You can see the exact meaning of my feature suggestion in the example below :
Untitled-1

Since there is just one children item size for the whole draggable module and you determine the number of each view on a row based on that, this is what happening now :
Untitled-2

Thank you

2 drag and drop zones

Is it possible to move an item from drag and drop zone to another?

Imagine like this
Day 1

  • Item 1
  • Item 2

Day 2

  • Item 3
  • Item 4

Like i want to move Item 1 to day2?

Item does not scale back to normal size on drop

When an item is dragged it scales up but when it is released it does not scale back to normal (see attached screenshot).

This seems due to an error in the endTouch method, which is responsible to scale the item back to its normal size. This method starts the animation to scale the item back but then calls the changePosition method which triggers a re-render and interrupts the animation.

Please, review MR #43 which fixes this.

Screenshot 2019-11-04 at 16 18 54

Sortable = {false} does not prevent DragSortableView from dragging

Sortable = {false} does not prevent DragSortableView from dragging

<DragSortableView
sortable={false}
dataSource={this.state.appList}
parentWidth={parentWidth}
childrenWidth={childrenWidth}
childrenHeight={childrenHeight}
marginChildrenRight={marginChildrenRight}
marginChildrenLeft={marginChildrenLeft}
marginChildrenTop={marginChildrenTop}
marginChildrenBottom={marginChildrenBottom}
onClickItem={(data, item, index) => { this._onPressItem(item) }}
renderItem={(item, index) =>
<View style={{ width: childrenWidth, height: childrenHeight }}>


}
/>

"dependencies": {
"native-base": "^2.2.1",
"react": "^16.0.0-alpha.12",
"react-dom": "^15.6.1",
"react-native": "0.52.0",
"react-native-base64": "0.0.2",
"react-native-cached-image": "^1.4.3",
"react-native-check-box": "^2.1.6",
"react-native-device-info": "^0.22.2",
"react-native-dialog": "^5.1.0",
"react-native-doc-viewer": "^2.7.8",
"react-native-drag-sort": "^1.0.2",
"react-native-fingerprint-scanner": "^2.5.0",
"react-native-firebase": "4.3.0",
"react-native-keyboard-aware-scroll-view": "^0.3.0",
"react-native-keyboard-listener": "^1.1.0",
"react-native-keychain": "^1.2.1",
"react-native-modal": "^6.5.0",
"react-native-modal-popover": "0.0.10",
"react-native-navigation": "1.1.483",
"react-native-permissions": "^1.1.1",
"react-native-segmented-control-tab": "^3.3.1",
"react-native-version-number": "^0.3.4",
"react-navigation": "^1.0.0-beta.11",
"sprintf-js": "^1.1.1",
"string": "^3.3.3"
},

安卓机型上拖拽还是会卡

机子:锤子坚果3
RN版本:0.44
效果:直接demo拷到项目中拖拽真机上使用还是非常卡。并且touchend后会提示错误

希望抽空解决下,谢谢!

DragSortableView Does not work inside ScrollView

<ScrollView srcollEnabled={this.state.scrollEnabled}>
    <DragSortableView
         dataSource={this.state.profilePic}
         parentWidth={Dimensions.get('window').width}
         childrenWidth= {width}
         childrenHeight={width}
         marginChildrenTop={20}
         marginChildrenLeft={10}
         marginChildrenRight={10}
         onDragStart={() => this.setState({scrollEnabled: false})}
         onDragEnd={() => this.setState({scrollEnabled: true})}
         fixedItems={this.getFixedItems()}
         onDataChange={(data) => this.setState({profilePic: data})}
         onClickItem={this.onItemPress}
         keyExtractor={(item, index)=> `${index}_${parseInt(Math.random()*10000)}`}
         renderItem={this.renderProfilePicture}
    />
</ScrollView>

DragSortableView works fine if it is not inside ScrollView, but inside ScrollView when I call this.setState() onDragStart, screen freezes and it cannot be dragged.

列表拖动有点卡,iOS CPU上涨

 <ScrollView
        ref={scrollView => (this.scrollView = scrollView)}
        scrollEnabled={scrollEnabled}
        style={styles.container}>
        <DraggableFlatList
          dataSource={fundData.slice()}
          parentWidth={parentWidth}
          childrenWidth={childrenWidth}
          childrenHeight={childrenHeight}
          scaleStatus={'scaleY'}
          onDragStart={(startIndex, endIndex) => {
            model.setScrollEnable(false)
          }}
          onDragEnd={startIndex => {
            model.setScrollEnable(true)
          }}
          onDataChange={data => {
            if (data.length !== fundData.length) {
              model.resetData(data)
            }
          }}
          keyExtractor={(item, index) => item.name}
          onClickItem={(data, item, index) => {}}
          renderItem={(item, index) => {
            return this.renderItem(item, index)
          }}
        />
      </ScrollView>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.