Giter Site home page Giter Site logo

react-native-draggable-flatlist's Introduction

⚠️ You are viewing the README for v4 (view v3, v2 )

React Native Draggable FlatList

A drag-and-drop-enabled FlatList component for React Native.
Fully native interactions powered by Reanimated and React Native Gesture Handler.

To use swipeable list items in a DraggableFlatList see React Native Swipeable Item.

Draggable FlatList demo

Install

  1. Follow installation instructions for reanimated and react-native-gesture-handler. RNGH may require you to make changes to MainActivity.java. Be sure to follow all Android instructions!
  2. Install this package using npm or yarn

with npm:

npm install --save react-native-draggable-flatlist

with yarn:

yarn add react-native-draggable-flatlist
  1. import DraggableFlatList from 'react-native-draggable-flatlist'

Api

Props

All props are spread onto underlying FlatList

Name Type Description
data T[] Items to be rendered.
ref React.RefObject<FlatList<T>> FlatList ref to be forwarded to the underlying FlatList.
renderItem (params: { item: T, getIndex: () => number | undefined, drag: () => void, isActive: boolean}) => JSX.Element Call drag when the row should become active (i.e. in an onLongPress or onPressIn).
renderPlaceholder (params: { item: T, index: number }) => React.ReactNode Component to be rendered underneath the hovering component
keyExtractor (item: T, index: number) => string Unique key for each item (required)
onDragBegin (index: number) => void Called when row becomes active.
onRelease (index: number) => void Called when active row touch ends.
onDragEnd (params: { data: T[], from: number, to: number }) => void Called after animation has completed. Returns updated ordering of data
autoscrollThreshold number Distance from edge of container where list begins to autoscroll when dragging.
autoscrollSpeed number Determines how fast the list autoscrolls.
animationConfig Partial<WithSpringConfig> Configure list animations. See reanimated spring config
activationDistance number Distance a finger must travel before the gesture handler activates. Useful when using a draggable list within a TabNavigator so that the list does not capture navigator gestures.
onScrollOffsetChange (offset: number) => void Called with scroll offset. Stand-in for onScroll.
onPlaceholderIndexChange (index: number) => void Called when the index of the placeholder changes
dragItemOverflow boolean If true, dragged item follows finger beyond list boundary.
dragHitSlop object: {top: number, left: number, bottom: number, right: number} Enables control over what part of the connected view area can be used to begin recognizing the gesture. Numbers need to be non-positive (only possible to reduce responsive area).
debug boolean Enables debug logging and animation debugger.
containerStyle StyleProp<ViewStyle> Style of the main component.
simultaneousHandlers React.Ref<any> or React.Ref<any>[] References to other gesture handlers, mainly useful when using this component within a ScrollView. See Cross handler interactions.
itemEnteringAnimation Reanimated AnimationBuilder (docs) Animation when item is added to list.
itemExitingAnimation Reanimated AnimationBuilder (docs) Animation when item is removed from list.
itemLayoutAnimation Reanimated AnimationBuilder (docs) Animation when list items change position (enableLayoutAnimationExperimental prop must be true).
enableLayoutAnimationExperimental boolean Flag to turn on experimental support for itemLayoutAnimation.

Cell Decorators

Cell Decorators are an easy way to add common hover animations. For example, wrapping renderItem in the <ScaleDecorator> component will automatically scale up the active item while hovering (see example below).

ScaleDecorator, ShadowDecorator, and OpacityDecorator are currently exported. Developers may create their own custom decorators using the animated values provided by the useOnCellActiveAnimation hook.

Nesting DraggableFlatLists

It's possible to render multiple DraggableFlatList components within a single scrollable parent by wrapping one or more NestableDraggableFlatList components within an outer NestableScrollContainer component.

NestableScrollContainer extends the ScrollView from react-native-gesture-handler, and NestableDraggableFlatList extends DraggableFlatList, so all available props may be passed into both of them.

Note: When using NestableDraggableFlatLists, all React Native warnings about nested list performance will be disabled.

import { NestableScrollContainer, NestableDraggableFlatList } from "react-native-draggable-flatlist"

...

  const [data1, setData1] = useState(initialData1);
  const [data2, setData2] = useState(initialData2);
  const [data3, setData3] = useState(initialData3);

  return (
    <NestableScrollContainer>
      <Header text='List 1' />
      <NestableDraggableFlatList
        data={data1}
        renderItem={renderItem}
        keyExtractor={keyExtractor}
        onDragEnd={({ data }) => setData1(data)}
      />
      <Header text='List 2' />
      <NestableDraggableFlatList
        data={data2}
        renderItem={renderItem}
        keyExtractor={keyExtractor}
        onDragEnd={({ data }) => setData2(data)}
      />
      <Header text='List 3' />
      <NestableDraggableFlatList
        data={data3}
        renderItem={renderItem}
        keyExtractor={keyExtractor}
        onDragEnd={({ data }) => setData3(data)}
      />
    </NestableScrollContainer>
  )

Nested DraggableFlatList demo

Example

Example snack: https://snack.expo.dev/@computerjazz/draggable-flatlist-examples

import React, { useState } from "react";
import { Text, View, StyleSheet, TouchableOpacity } from "react-native";
import DraggableFlatList, {
  ScaleDecorator,
} from "react-native-draggable-flatlist";

const NUM_ITEMS = 10;
function getColor(i: number) {
  const multiplier = 255 / (NUM_ITEMS - 1);
  const colorVal = i * multiplier;
  return `rgb(${colorVal}, ${Math.abs(128 - colorVal)}, ${255 - colorVal})`;
}

type Item = {
  key: string;
  label: string;
  height: number;
  width: number;
  backgroundColor: string;
};

const initialData: Item[] = [...Array(NUM_ITEMS)].map((d, index) => {
  const backgroundColor = getColor(index);
  return {
    key: `item-${index}`,
    label: String(index) + "",
    height: 100,
    width: 60 + Math.random() * 40,
    backgroundColor,
  };
});

export default function App() {
  const [data, setData] = useState(initialData);

  const renderItem = ({ item, drag, isActive }: RenderItemParams<Item>) => {
    return (
      <ScaleDecorator>
        <TouchableOpacity
          onLongPress={drag}
          disabled={isActive}
          style={[
            styles.rowItem,
            { backgroundColor: isActive ? "red" : item.backgroundColor },
          ]}
        >
          <Text style={styles.text}>{item.label}</Text>
        </TouchableOpacity>
      </ScaleDecorator>
    );
  };

  return (
    <DraggableFlatList
      data={data}
      onDragEnd={({ data }) => setData(data)}
      keyExtractor={(item) => item.key}
      renderItem={renderItem}
    />
  );
}

const styles = StyleSheet.create({
  rowItem: {
    height: 100,
    width: 100,
    alignItems: "center",
    justifyContent: "center",
  },
  text: {
    color: "white",
    fontSize: 24,
    fontWeight: "bold",
    textAlign: "center",
  },
});

react-native-draggable-flatlist's People

Contributors

aeisenberger avatar batuhansahan avatar brunohkbx avatar buzzhoot avatar callaars avatar cc-matthias-m avatar chungweileong94 avatar computerjazz avatar curiousdustin avatar danijelbojcic avatar dcvz avatar dependabot[bot] avatar ericdolson avatar evrimfeyyaz avatar frankyfrankfrank avatar fredrivett avatar hsource avatar kevgrig avatar magrinj avatar mirkorainer avatar mortenjoe avatar naturalclar avatar nsainaney avatar pirroman avatar rgoldiez avatar shamblid avatar srbrahma avatar svarto avatar websurgeon avatar ymatsushita2019 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-draggable-flatlist's Issues

Support dnd between flatlists

Any plans on supporting this or suggestions on how to to it?

Looking for a way to implement trello/kanban style dnd between horizontal flatlists and this is the closest thing I have found for React Native so it would be awesome.

Item position offset on move begin and end

Hi everyone,

Not a huge deal, but there seems to be an unwanted position offset when selecting/releasing an item. As seen on the GIF attached, the item moves upwards when the long press is detected, as well as when it is released (before moving to its final position). Any thoughts ?

This is the code from the example, running on an android phone through Expo.

draggable_flatlist_offset

FlatList animation performance

Hey @computerjazz!

This isn't an issue with your library but we've found a performance issue with Animated FlatList's. If you instead use a SectionList with one section you'll see smooth animations with animated values.

<FlatList data={[1,2,3]} />
// =>
<SectionList sections={[{ data: [1,2,3]}]} />

Sounds stupid, but it's the only way we've found to fix it until the root issues with FlatList are resolved. facebook/react-native#24364

I don't believe there's any downsides to using this approach.

hoverComponent wrongly positioned

Hello, I'm experiencing an issue where hoverComponent is wrongly positioned to the left, approximately about -100px left.
This issue happens only on iOS (simulator and device) when testing the Release build (debug build works fine).

Xcode 10.2.1
iPhone 7 Plus - 12.2

I'm attaching the gif file where you can see the behavior.
Also, it seems that everything works fine when there are only two items in the list.

release_ios

Animations are choppy in Android

When running the demo/example on a fresh Expo project (CRNA), the animation for dragging and dropping are choppy (i.e. when I pick up an item, it “jumps” up and when I put it to a position, it jumps from the released position to its intended position).

Note that this doesn’t affect the iOS version of the app.

I’ll get back with a demo once I am able to record it.

Deleting/Adding items

There is some problem with adding and removing items from the list. All javascript becomes unresponsive. There is a memory leak somewhere and after a while, the RAM usage will increase and crash the app. Is there a way to add and delete items?

undefined is not an object (evaluating 'p.height') Android

After rearranging a couple of items, sometimes the app crashes with the following error.

Android Version: 6.0

E/AndroidRuntime: FATAL EXCEPTION: mqt_native_modules
    Process: com.example, PID: 13113
    com.facebook.react.common.JavascriptException: undefined is not an object (evaluating 'p.height'), stack:
    onPanResponderRelease@597:6166
    S@262:2929
    onResponderRelease@262:2858
    g@66:551
    S@66:694
    P@66:748
    z@66:1913
    j@66:2675
    D@66:2472
    <unknown>@66:14047
    Ie@66:70003
    Me@66:13717
    De@66:13890
    receiveTouches@66:14710
    value@18:3477
    <unknown>@18:959
    value@18:2721
    value@18:931
    
        at com.facebook.react.modules.core.ExceptionsManagerModule.showOrThrowError(ExceptionsManagerModule.java:54)
        at com.facebook.react.modules.core.ExceptionsManagerModule.reportFatalException(ExceptionsManagerModule.java:38)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
        at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:160)
        at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
        at android.os.Handler.handleCallback(Handler.java:739)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
        at android.os.Looper.loop(Looper.java:148)
        at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192)
        at java.lang.Thread.run(Thread.java:818)

Support for flat list with columns

This works very nice with single column FlatList but drag and drop fails when working with multiple columns. Like for example I can only drag the item up and down not side ways, so I cant move item form column 1 to column 2.

Do you have ideas how can I achieve this? I have also attached screenshot to show what I am talking about.

Thanks for this.
img_2bea02ddd87e-1

list disappear after drag n drop with some error

"react-native": "0.55.4",
"react-native-draggable-flatlist": "^1.1.2",

listerror

this is what i done:

<DraggableFlatList
          data={this.state.rowData}
          renderItem={this.renderRowItem}
          scrollPercent={5}
          keyExtractor={(item, index) => `draggable-item-${index}`}
          onMoveEnd={({ rowData }) => this.setState({ rowData })}
    />

renderRowItem = ({ item, index, move, moveEnd, isActive }) => {
    return (
      <TouchableOpacity
        onLongPress={move}
        onPressOut={moveEnd}
        style={{
          height: 100,
          alignItems: 'center',
          justifyContent: 'center'
        }}
      >
      <Text>{item.name}</Text>
      {/*   <Row data={item} active={active} columnSchema={this.state.columnSchema} searchValue={this.state.searchValue} />; */}
      </TouchableOpacity>
    )
  }

i m getting list successfully. but after drag it just disappear.

StatusBar hidden issue

The animated component offset jumps up by the height of the statusbar if statusbar is rendered <StatusBar hidden = {true}, had to add translucent true as so: <StatusBar hidden = {true} translucent = {true} /> to force that statusbar offset to be subtracted.

Drag-and-Drop not working on Android (RN 0.57.0)

Issue

Item dragging functionality does not work on Android for RN 0.57.0

This is not an issue on react-native <= 0.56.0

Thanks to computerjazz and contributors for making this a very useful component.
I hope a solution can be found soon.

If I find the cause of this issue I'll provide a PR a.s.a.p.

Expected behaviour

Item spacer should appear and move between items when an item is being dragged.
Releasing the dragged item should drop it onto the spacer location.

Actual behaviour

Works as expected on iOS but on Android the spacer does not appear and the dragged item (which is removed from the list) hovers over other items but is just left wherever it is dropped.
On attempting to drag another item, the initially dropped item (that was left overlapping other items) jumps to the new drag location and becomes the currently dragged item (as if the previous drag-and-drop never completed).

I have confirmed this issue exists for emulators and devices.

Environment being tested on:

This was tested with a clean 'react-native init MyApp --version 0.57.0' generated project. Replacing App.js code with the Example code.

$ react-native info

React Native Environment Info:
    System:
      OS: macOS High Sierra 10.13.6
      CPU: x64 Intel(R) Core(TM) i5-4570 CPU @ 3.20GHz
      Memory: 37.84 MB / 16.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 8.11.3 - ~/.nvm/versions/node/v8.11.3/bin/node
      Yarn: 1.9.4 - ~/.nvm/versions/node/v8.11.3/bin/yarn
      npm: 5.6.0 - ~/.nvm/versions/node/v8.11.3/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 11.4, macOS 10.13, tvOS 11.4, watchOS 4.3
      Android SDK:
        Build Tools: 23.0.1, 23.0.3, 25.0.0, 25.0.1, 26.0.1, 26.0.2, 26.0.3, 27.0.3, 28.0.2
        API Levels: 23, 24, 25, 26, 27, 28
    IDEs:
      Android Studio: 3.1 AI-173.4907809
      Xcode: 9.4.1/9F2000 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.5.0 => 16.5.0 
      react-native: 0.57.0 => 0.57.0 
    npmGlobalPackages:
      react-native-cli: 2.0.1

Android hiding items after dragging a few times

Hey @computerjazz

First of all, crisp component - its super awesome to work with! Well on iOS at least :( After implementing this, i noticed that some of my items started to dissapear after dragging them a few times. Then i figured out they would just lay below other list items.

Afterwards I replicated this in the example code

Steps to replicate
Drag several times, possibly if you drag an item several spots towards the top.

Screenshot
thumbnail_Screenshot_20190429-234859

Tested on a Huaweii P20 Lite

Setup
"react-native": "0.59.2",
"react": "16.8.3",
"react-native-draggable-flatlist": "^1.1.7",

extraData can't use

Hello, some one can help me fix my problem? I want to re-render my layout, but extraData can't working fine...
screen shot 2018-08-13 at 12 55 27 pm

Dragging immediately

Hi there. Is there a way to drag immediately on press without waiting long press?

Please add a license

This project does not have a license and GitHub states, "[...] without a license, the default copyright laws apply, meaning that you retain all rights to your source code and no one may reproduce, distribute, or create derivative works from your work. If you're creating an open source project, we strongly encourage you to include an open source license."

Can you please consider adding an open source license such as MIT? Otherwise, I am not a lawyer, but I believe that no one may actually use this code in a production project (which would be reproducing and distributing it) without your explicit permission.

Component not rendering at all

The following code is not rendering anything at all

<DraggableFlatList data={['a', 'b', 'c']} renderItem={({ item }) => ( <Text>{item}</Text> )} keyExtractor={item => item} scrollPercent={5} />

How drag between multiple rows?

Is is possible to make the items draggable vertically and horizontally at the same time? I set horizontal to ‘true’ and turned it into 2 rows. However, I could only drag the items within the same row. Is is possible to drag swap Item 1 with Item 4?
Screenshot_1563337248

List Item jumps 44 points down on long press when animation starts

First off, nice job. This is the first drag drop component I found that was adaptable to my project. I am having an issue with this component. It works fine until I attempt to dynamically add another component which adds additional height to the container. My markup is as follows in the render function:

<View style={Styles.container}>
	{this._renderListAddSection()}
	<View style={{ flex: 1 }}>
		<DraggableFlatList
			isModerator={sessionModerator}
			// contentContainerStyle={Styles.contentContainer}
			data={this.state.data}
			renderItem={this._renderItem}
			scrollPercent={5}
			onMoveEnd={this._onMoveEnd}
		/>
	</View>
	<ButtonAction
		onClickHandler={this.onActionPress}
		active={listPending}
	/>
	<ListItemAdd
		visible={this.state.addModalVisible}
		closeModal={this.closeAddListModal}
		userId={this.props.user.id}
	/>
</View>

When the component initially loads it works as expected. The app allows a person to take administrative privileges by selecting a button in the header. That re renders the component and runs the _renderListAddSection method with basically adds another component to the view that has additional buttons

<ListAdd
	onPressHandler={this.openAddListModal}
	title="Tap to add a name"
/>

After the additional component is added with a height of 44 your component basically starts behaving unexpectedly. When long pressing the active row jumps 44 points down when activated. I have tried for a day to figure out why and am hoping you might be able to understand the issue.

It's weird because the layout seems to adjust accordingly. Before the additional component is added the layout log you added reports a height of 812 and after it update following the component being added it reports 768 as the height, which is 812 - 768 = 44 which is the additional height of the added component.

So the problem is after adding the new component, when I press on the row to drag, instead of it becoming active in hover mode and simply changing opacity in the position it was in, it jumps down the amount of points of the added component.

Thanks.

Problem with the scrolling behaviour while selecting the first or last element

First of all, great tool! Thank you for your time developing this.

While using the default example, I encountered a small bug regarding the scrolling behaviour. When selecting the first element, scroll down a bit. You will realize the scrolling-up will not work (while still holding the same element). If you pick the second element it will work just fine. The same behaviour is seen when dragging the last element up and trying to scroll back down while still holding it.

I am using the following versions:
"react": "16.8.3"
"react-native": "0.58.6"
"react-native-draggable-flatlist": "^1.1.7"

Android crash

Hi all,
So this module appears to work really well in iOS but I'm getting the following crash on android.
com.facebook.react.bridge.ReadableNativeMap.getValue
ReadableNativeMap.java - line 122
com.facebook.react.bridge.NoSuchKeyException: translateY

Anyone else? Ideas? It happens the moment I long click the item I want to move.

Is there any prop to enable or disable draggable feature?

I have only one component and I am rendering it on two separate screens, on one screen I have to enable the drag feature but on the other screen I have to disable the drag feature. What can I do? Let me know, if any prop is available!

<DraggableFlatList enable={ true || false }  />

Thanks in advance! 😊〽

when performing an update on the content, this does not reflect for the listing

I am updating the content of DraggableFlatList, in the data attribute via redux, but I noticed that when updating in the variable that is defined in the date, it does not update the listing, this only occurs when the drag drop

Example with DraggableFlatList:

com draggableflatlist

code:

<DraggableFlatList
        data={data}
        renderItem={this.renderItem}
        keyExtractor={item => `key-${item.interno}`}
        scrollPercent={5}
        onMoveEnd={({ data }) => this.props.ordenacaoActions.setOrderUnidadesRequest({ data })}
        contentContainerStyle={{ marginHorizontal: metrics.baseMargin }}
        ItemSeparatorComponent={() => <View style={styles.separator} />}
      />

Example without DraggableFlatList and use original FlatList

flatlist

code:

<FlatList
        data={data}
        renderItem={this.renderItem}
        keyExtractor={item => `key-${item.interno}`}
        scrollPercent={5}
        onMoveEnd={({ data }) => this.props.ordenacaoActions.setOrderUnidadesRequest({ data })}
        contentContainerStyle={{ marginHorizontal: metrics.baseMargin }}
        ItemSeparatorComponent={() => <View style={styles.separator} />}
      />

I believe the lib, is not considering in your shouldComponentUpdate when there is update in the input values, or something of the genre ...

Am I correct about this procedure?

Draggable Flatlist inside a ScrollView doesn't account for scrolled offset

When nesting a DraggableFlatlist inside a ScrollView the proxy components rendered while dragging are not positioned relative to the scrolled position of the parent container (the ScrollView).

This means they either disappear or render offset from the mouse/touch position by the scrolled amount.

In the below test case, I'm offsetting the position of the draggable flatlist using content container padding on the ScrollView. Dragging/re-ordering still works by disabling the scrollview with onMoveBegin

I would guess that you need to position the proxy component absolutely to the touch position within the screen, not just the view.

import React, { PureComponent } from 'react';
import { ScrollView, Text, TouchableOpacity } from 'react-native';
import DraggableFlatList from 'react-native-draggable-flatlist';

export default class Test extends PureComponent {
  state = {
    scrollEnabled: true,
    data: [
      { label: '1', key: '1' },
      { label: '2', key: '2' },
      { label: '3', key: '3' },
      { label: '4', key: '4' },
    ],
  };

  renderItem = ({
    item, isActive, index, move, moveEnd,
  }) => (
    <TouchableOpacity
      activeOpacity={0.9}
      style={{
        flex: 1,
        alignItems: 'center',
        height: 60,
        borderColor: isActive ? 'white' : 'black',
        borderWidth: 2,
      }}
      onLongPress={move}
      onPressOut={moveEnd}
    >
      <Text style={{ fontSize: 30, color: 'white' }}>
        {item.label}
      </Text>
    </TouchableOpacity>
  );

  render() {
    return (
      <ScrollView
        style={{ backgroundColor: '#000' }}
        contentContainerStyle={{ paddingTop: 800, paddingBottom: 100 }}
        scrollEnabled={this.state.scrollEnabled}
      >
        <DraggableFlatList
          scrollPercent={5}
          data={this.state.data}
          renderItem={this.renderItem}
          keyExtractor={item => `draggable-item-${item.key}`}
          onMoveBegin={() => this.setState({ scrollEnabled: false })}
          onMoveEnd={({ data }) => {
            this.setState({ scrollEnabled: true, data });
          }}
        />
      </ScrollView>
    );
  }
}

Multiple level of draggable flatlist

Is it possible that i can have draggable flatlist inside another draggable flatlist ?
I tested but in second level of item keep hanging on the same position when dragging.

Anyone can help me on this ? Really appreciate if you could help me.

itemChild = (item) => {
return(
<DraggableFlatList
data={item.item}
renderItem={this.renderItem}
keyExtractor={(items, indexs) => draggable-item-${items.key}}
scrollPercent={5}
onMoveEnd={({ datas }) => this.setState({ testing: datas })}
/>
)
}

renderItem = ({ item, index, move, moveEnd, isActive }) => {
return (
<View style={{
marginBottom: 5,
paddingHorizontal: 15, paddingVertical: 10,
backgroundColor: isActive ? '#fcfcfc' : '#fff',
elevation: isActive ? 3 : 0,
}}
>
<View style={{ flexDirection: 'row', alignItems: "center" }}>
<TouchableOpacity
style={{ height: 40, justifyContent: 'center'}}
onLongPress={move}
onPressOut={moveEnd}
>
{ item.label }


<View style={{ flex: 1 }}>
{ this.itemChild(item) }


)
}

render() {
return(
<View style={{ flex: 1 }}>
<DraggableFlatList
data={this.state.layout}
renderItem={this.renderItem}
keyExtractor={(item, index) => draggable-item-${item.key}}
scrollPercent={5}
onMoveEnd={({ data }) => this.setState({ layout: data })}
/>

)
}

Is there any way to use scrollEnabled?

i know that its props are underlying FlatList and Flatlist is using ScrollView's props.

but I can't use scrollEnabled.

i wanna make this component disabled when single renderItem swiping horizontally.

is there any way please..?😄

react-native dropdown with flat list

I am a begginner in react-native as well as coding too.
I need to show a flat list having multiple details under a down list . Can anyone help please..

Here i am attaching the sketch which i meant to be....

gitt

## measure error -- index: 0 -1

Hi
I'm implementing this library in my project.
I am importing this : import DraggableFlatList from 'react-native-draggable-flatlist'
in two different components and I set different data through the
data1.js
<DraggableFlatList
data={this.props.data1}

data2.js
<DraggableFlatList
data={this.props.data}

After a while I get this error :

measure error -- index: 0 -1

Error: Unable to find node on an unmounted component.

Do you know why?
Thanks

Implementation Question

First of all thank you for your work on this great component,

This isn't really an issue but more of a question, however I wasn't sure where else to ask.

I am implementing a draggable flatlist and trying to display a travel time between (and overlapping) two rows. I cannot for the life of me figure out how to force the child view of the first row not to be clipped by the next row in the flatlist. The view is positioned correctly and when the row is being dragged everything displays correctly.

I have tried using overflow='visible', removeClippedSubviews={false}, and position: 'absolute' but haven't been able to find a solution.

If there is another approach that I am missing to accomplishing this please let me know.

Thanks

Running example code, many problems

I was very excited about your library and thank you for putting so much time and effort into making and sharing your code.

However, I find it hugely disappointing as it simply does not work very well.
Take a look, releasing items too early will cause it to not be dropped, sometimes re-ordered items cause them to render only white, scrolling while dragging is really laggy, and lastly the offset seems very off.

test

critical bug

OS: Android 8.0
RN: 57.7
react-native-draggable-flatlist - latest
On drag, when the animation has not finished yet, but we have moved the element to the place where the animation ends.
Result: the item disappears.
Expected: normal behavior.
ezgif-3-761e3193f71f

It happens when spacerIndex and activeRow is equal.

Offset not recalculated if container layout changes

STEPS

  1. Create a list that takes up half the screen.
  2. Add a button that changes the styling of the list to take up the full screen (or some other size)

EXPECTED
Drag & drop still works correctly

ACTUAL
The drag & drop works but the item being dragged isn't shown in the right location.

Maximum Update depth error

I’m using the draggable flatlist and whenever the data array passed to it changes frequently it causes a maximum update depth error and the whole app becomes non responsive.

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.