1.0.24 • Published 3 years ago

react-native-drop-zone v1.0.24

Weekly downloads
20
License
Hippocratic-2.1
Repository
github
Last release
3 years ago

React Native Drop Zone

React Native Drop Zone makes it easy to support across-app drag-n-drop function to your iOS App! It uses UIDropInteraction & UIDragInteraciton, which makes it comprehensive and simple to use.

Features

  • Native iOS Drag & Drop Session Implemented in Swift
  • Multiple Files Dropping
  • Support Multiple Drag Items
  • Customized Preview for Dragged Items
  • Six Drop Events & Three Drag Events
  • Six Drop Item Types & Three Drag Item Types
  • Edit Droppable Data Types

Installation

1. Install react-native-drop-zone

npm install react-native-drop-zone --save

2. Link to the library to your project

react-native link react-native-drop-zone

3. Go to your ios folder and run

pod install

Demo

Dropping Multiple Files

Dropping Text & Image

Dragging Image

Dragging Text & URL

Customized Preview for Dragging

Run Example

1. Download Example

git clone https://github.com/WeTransfer/react-native-drop-zone.git

2. Building the JavaScript components

cd react-native-drop-zone/Example
npm install

3. Launching the Packager

npm start

4. Run the project on iPad

Open the .xcworkspace file in the ios folder. Run and build the project on XCode (iPad) to check out our example.

Requirements

  • Swift 5.0
  • iOS 11.0+

Usage

Quick Start

Drop

<DropZone
  onDragOver={onDragOver}
  onDrop={onDrop}
  allowedDataTypes={['text', 'url', 'image']}
>
</DropZone>

onDrop(data: {[type: string]: any}) {
  console.log(data);
}
onDragOver(point: any) {
  console.log(point);
}

Drag

<DragView
  context={['Hello World', 'www.apple.com']}
></DragView>

// Customized Preview
<DragView
	dragPreview={<Text>Hellow World</Text>}
  context={['Hello World']}
></DragView>

Drop Props

NameTypeDescriptionDefault
allowedDataTypesstring[]Array of data types that are allowed in the dropping sessionAll Data Types
onDragEnterfunction({dropPoint: {x: number, y: number}})The drop session has moved into the drop interaction's viewN/A
onDragOverfunction({dropPoint: {x: number, y: number}})The drop session has changedN/A
onDragLeavefunction()The drop session has moved out of the drop interaction's viewN/A
onDragExitfunction()The drop session has endedN/A
onProcessingDropfunction({dropPoint: {x: number, y: number}})It starts to processing the data from the drag items.N/A
onDropfunction({data: {dropPoint: {x: number, y: number}}, texts: string[], urls: string[], files: string[]})It completes processing the data from the drag itemsN/A

Drag Props

NameTypeDescriptionDefault
contextstring[]Array of drag itemsN/A
onDragBeginfunction()The lift animation has finished and the user is starting to move the items across the screen.N/A
onDragOverfunction({dropPoint: {x: number, y: number}})The user starts to move the drag itemsN/A
OnDragEndfunction()The drag activity and its related animations have finished.N/A
dragPreviewReact.ReactNodeCustomized preview for dragged itemsN/A

Available Data Types

  • Drop

    Text, URL, Image, Video, Audio, Other

  • Drag

    Text, URL, Image

Documentation

Contributing

As the creators, and maintainers of this project, we're glad to invite contributors to help us stay up to date. Please take a moment to review the contributing document in order to make the contribution process easy and effective for everyone involved.

  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

License

React Native Drop Zone is available under the Hippocratic-2.1 license. See the LICENSE file for more info.

1.0.24

3 years ago

1.0.23

3 years ago

1.0.22

3 years ago

1.0.21

3 years ago

1.0.19

3 years ago

1.0.20

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago