2.7.6 • Published 3 years ago

@upacyxou/react-native-draggable-flatlist v2.7.6

Weekly downloads
1
License
MIT
Repository
github
Last release
3 years ago

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

NameTypeDescription
dataT[]Items to be rendered.
horizontalbooleanOrientation of list.
renderItem(params: { item: T, index: number, drag: () => void, isActive: boolean}) => JSX.ElementCall drag when the row should become active (i.e. in an onLongPress or onPressIn).
renderPlaceholder(params: { item: T, index: number }) => React.ReactNodeComponent to be rendered underneath the hovering component
keyExtractor(item: T, index: number) => stringUnique key for each item
onDragBegin(index: number) => voidCalled when row becomes active.
onRelease(index: number) => voidCalled when active row touch ends.
onDragEnd(params: { data: T[], from: number, to: number }) => voidCalled after animation has completed. Returns updated ordering of data
autoscrollThresholdnumberDistance from edge of container where list begins to autoscroll when dragging.
autoscrollSpeednumberDetermines how fast the list autoscrolls.
onRef(ref: React.RefObject<DraggableFlatList<T>>) => voidReturns underlying Animated FlatList ref.
animationConfigPartial<Animated.SpringConfig>Configure list animations. See reanimated spring config
activationDistancenumberDistance 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.
layoutInvalidationKeystringChanging this value forces a remeasure of all item layouts. Useful if item size/ordering updates after initial mount.
onScrollOffsetChange(offset: number) => voidCalled with scroll offset. Stand-in for onScroll.
onPlaceholderIndexChange(index: number) => voidCalled when the index of the placeholder changes
dragItemOverflowbooleanIf true, dragged item follows finger beyond list boundary.
dragHitSlopobject: {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).
debugbooleanEnables debug logging and animation debugger.

Example

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

const exampleData = [...Array(20)].map((d, index) => ({
  key: `item-${index}`, // For example only -- don't use index as your key!
  label: index,
  backgroundColor: `rgb(${Math.floor(Math.random() * 255)}, ${index *
    5}, ${132})`
}));

class Example extends Component {
  state = {
    data: exampleData
  };

  renderItem = ({ item, index, drag, isActive }) => {
    return (
      <TouchableOpacity
        style={{
          height: 100,
          backgroundColor: isActive ? "blue" : item.backgroundColor,
          alignItems: "center",
          justifyContent: "center"
        }}
        onLongPress={drag}
      >
        <Text
          style={{
            fontWeight: "bold",
            color: "white",
            fontSize: 32
          }}
        >
          {item.label}
        </Text>
      </TouchableOpacity>
    );
  };

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

export default Example;
absolute-pathabort-controlleransi-colorsacceptsansi-cyanansi-escapesansi-fragmentsansi-grayansi-redansi-regexansi-wrapansi-stylesargparsearr-diffanymatcharr-unionarr-flattenarray-differarray-maparray-filterarray-slicearray-reducearray-uniquearray-unionarrifyartasapassign-symbolsastral-regexasyncasync-limiteratobbabel-plugin-dynamic-import-nodebabel-plugin-syntax-trailing-function-commasbabel-preset-fbjsbasebalanced-matchbase64-jsbasic-authbig-integerbplist-creatorbrace-expansionbplist-parserbuffer-crc32bracesbserbuffer-frombytescache-basecaller-callsitecaller-pathcamelcasecallsiteschalkcapture-exitchardetci-infoclass-utilscli-cursorcli-spinnerscli-widthclonecliuicode-point-atcollection-visitcolor-convertcolorettecolor-supportcolor-namecommand-existscommandercompare-versionscommondircompressiblecomponent-emittercompressionconcat-mapconcat-streamconvert-source-mapcopy-descriptorconnectcore-jscore-util-iscreate-react-classcosmiconfigcsstypecross-spawndayjsdebugdecamelizedeepmergedecode-uri-componentdefaultsdefine-propertiesdefine-propertydenodeifydestroydepdee-firstencodeurlencodingend-of-streamerror-exenvinfoerrorhandlerescape-htmlescape-string-regexpesprimaetagesutilsevent-target-shimeventemitter3exec-shexecaexpand-bracketsextend-shallowexternal-editorextglobfancy-logfbjsfb-watchmanfbjs-css-varsfbjs-scriptsfiguresfinalhandlerfill-rangefind-cache-dirfind-upfind-versionsfragment-cachefor-infreshfs-extrafunction-bindgensyncfs.realpathget-streamget-caller-fileget-valueglobglobalsgrowlygraceful-fshammerjshas-flaghas-symbolshas-valuehas-valueshoist-non-react-staticshosted-git-infohermes-enginehttp-errorsimage-sizeiconv-liteignoreimport-freshimurmurhashinflightinheritsinvariantinquirerinvert-kvis-accessor-descriptoris-bufferis-arrayishis-ciis-descriptoris-data-descriptoris-directoryis-extendableis-fullwidth-code-pointis-numberis-plain-objectis-promiseis-windowsis-streamis-wslisarrayisobjectisexejest-get-typejest-haste-mapisomorphic-fetchjest-message-utiljest-mockjest-utiljest-serializerjest-validatejest-workerjs-tokensjs-yamljetifierjsescjsc-androidjson-parse-better-errorsjson-stable-stringifykind-ofjson5jsonifyjsonfileklawlcidlevenlines-and-columnsload-json-filelocate-pathlogkittylog-symbolslodashlodash.throttleloose-envifymakeerrorlru-cachemap-age-cleanermake-dirmap-visitmap-cachememmerge-streammetro-babel-registermetrometro-configmetro-babel-transformermetro-coremetro-minify-uglifymetro-cachemetro-inspector-proxymetro-resolvermetro-react-native-babel-presetmetro-react-native-babel-transformermetro-source-mapmetro-symbolicatemicromatchmimemime-dbmimic-fnmime-typesminimistminimatchmkdirpmrimixin-deepmorganmsmultimatchmute-streamnanomatchnegotiatornode-fetchnice-trynode-int64normalize-package-datanode-modules-regexpnormalize-pathnpm-run-pathnullthrowsnumber-is-nanob1object-assignobject-copyobject-visitobject-keysobject.assignobject.pickonceon-headerson-finishedonetimeopenopencollective-postinstalloptionsoraos-tmpdiros-localep-deferp-finallyp-is-promisep-limitp-locatep-tryparent-moduleparse-jsonparse-node-versionparseurlpascalcasepath-is-absolutepath-keypath-existspath-parsepath-typepifynode-notifierpiratespkg-dirplease-upgrade-nodeposix-character-classesprivateplugin-errorplistpretty-formatpromiseprocess-nextick-argspumpprop-typespseudomapreact-devtools-corerange-parserreact-isreact-refreshread-pkgregenerateread-pkg-upreadable-streamregenerate-unicode-propertiesregenerator-runtimeregenerator-transformregex-notregexpu-coreregjsgenrepeat-stringregjsparserremove-trailing-separatorrepeat-elementrequire-directoryrequire-main-filenameresolveresolve-fromrestore-cursorresolve-urlretrsvprimrafrun-asyncrx-lite-aggregatesrx-literxjssafe-buffersafe-regexsaxsanesafer-bufferschedulersendsemver-comparesemversemver-regexserialize-errorsetimmediateset-blockingserve-staticset-valuesetprototypeofshebang-commandshebang-regexshellwordsshell-quotesignal-exitsimple-plistslashslice-ansislidesnapdragon-utilsnapdragon-nodesnapdragonsource-mapsource-map-resolvesource-map-supportsource-map-urlspdx-correctspdx-exceptionssplit-stringspdx-license-idsspdx-expression-parsestack-utilssprintf-jsstatic-extendstacktrace-parserstream-buffersstatusesstring-widthstring_decoderstrip-ansistrip-bomsudo-promptstrip-eofstrip-final-newlinesymbol-observablesupports-colortempthroughthroatthrough2tmptime-stamptmplto-object-pathto-fast-propertiesto-regextoidentifierto-regex-rangetype-festtypedarrayua-parser-jsuglify-esultronunicode-match-property-ecmascriptunicode-canonical-property-names-ecmascriptunion-valueunicode-match-property-value-ecmascriptunicode-property-aliases-ecmascriptunpipeuniversalifyunset-valueutil-deprecateurixuseuuidutils-mergevalidate-npm-package-licensevaryvlqwalkerwcwidthwhichwhatwg-fetchwhich-pm-runswhich-modulewrap-ansiwordwrapwswrappywrite-file-atomicxcodexmlbuilderxmldocxmldomxtendxpipey18nyallistyamlyargsyargs-parser
2.6.9999998

3 years ago

2.6.9999997

3 years ago

2.7.0

3 years ago

2.7.2

3 years ago

2.7.1

3 years ago

2.7.4

3 years ago

2.7.3

3 years ago

2.7.6

3 years ago

2.7.5

3 years ago

2.6.9999996

3 years ago

2.6.9999995

3 years ago

2.6.9999994

3 years ago

2.6.9999993

3 years ago

2.6.9999992

3 years ago

2.6.9999991

3 years ago

2.6.999999

3 years ago

2.6.999998

3 years ago

2.6.999997

3 years ago

2.6.999996

3 years ago

2.6.999995

3 years ago

2.6.999994

3 years ago

2.6.999993

3 years ago

2.6.999992

3 years ago

2.6.999991

3 years ago

2.6.99999

3 years ago

2.6.99998

3 years ago

2.6.99997

3 years ago

2.6.99996

3 years ago

2.6.99995

3 years ago

2.6.99994

3 years ago

2.6.99993

3 years ago

2.6.99992

3 years ago

2.6.99991

3 years ago

2.6.9999

3 years ago

2.6.9996

3 years ago

2.6.9995

3 years ago

2.6.9998

3 years ago

2.6.9997

3 years ago

2.6.9994

3 years ago

2.6.9993

3 years ago

2.6.9992

3 years ago

2.6.9991

3 years ago

2.6.998

3 years ago

2.6.999

3 years ago

2.6.997

3 years ago

2.6.91

3 years ago

2.6.92

3 years ago

2.6.93

3 years ago

2.6.94

3 years ago

2.6.99

3 years ago

2.6.95

3 years ago

2.6.96

3 years ago

2.6.97

3 years ago

2.6.98

3 years ago

2.6.61

3 years ago

2.6.66

3 years ago

2.6.62

3 years ago

2.6.63

3 years ago

2.6.64

3 years ago

2.6.65

3 years ago

2.6.996

3 years ago

2.6.994

3 years ago

2.6.995

3 years ago

2.6.992

3 years ago

2.6.993

3 years ago

2.6.991

3 years ago

2.6.7

3 years ago

2.6.6

3 years ago

2.6.9

3 years ago

2.6.8

3 years ago

2.6.5999

3 years ago

2.6.599

3 years ago

2.6.598

3 years ago

2.6.597

3 years ago

2.6.596

3 years ago

2.6.595

3 years ago

2.6.594

3 years ago

2.6.593

3 years ago

2.6.592

3 years ago

2.6.591

3 years ago

2.6.59

3 years ago

2.6.58

3 years ago

2.6.57

3 years ago

2.6.56

3 years ago

2.6.55

3 years ago

2.6.52

3 years ago

2.6.53

3 years ago

2.6.5

3 years ago

2.6.51

3 years ago

2.6.4

3 years ago

2.6.3

3 years ago

2.6.1

3 years ago

2.6.2

3 years ago

2.6.0

3 years ago

2.5.8

3 years ago

2.5.9

3 years ago

2.5.6

3 years ago

2.5.7

3 years ago

2.5.5

3 years ago

2.5.4

3 years ago

2.5.2

3 years ago

2.5.1

3 years ago

2.5.3

3 years ago

2.5.0

3 years ago