New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-dnd-multi-backend

Package Overview
Dependencies
Maintainers
1
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-dnd-multi-backend

Multi Backend system for React DnD

  • 2.1.8
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
78K
decreased by-5.83%
Maintainers
1
Weekly downloads
 
Created
Source

React DnD Multi Backend NPM Version

Try it here!

This project is a Drag'n'Drop backend compatible with React DnD. It enables your application to use different backends depending on the situation. The backend starts by using the React DnD HTML5 Backend, but switches to the React DnD Touch Backend if a touch event is triggered. You application can smoothly use the nice HTML5 compatible backend and fallback on the Touch one on mobile devices! Moreover, because the Touch backend doesn't support preview, a Preview component has been added to make it easier to mock the Drag'n'Drop "ghost".

Installation

npm install react-dnd-multi-backend

You can then use the minified UMD build in the dist folder. It exports a global window.ReactDnDMultiBackend when imported as a <script> tag. This file includes the HTML5 and Touch backends, so no need to include them as well.

Usage

You can plug this backend in the DragDropContext the same way you do for any backend (e.g. ReactDnDHTML5Backend), you can see the docs for more information.

You can also pass options to change the Backend behavior. Supported options are:

  • start: change the starting backend with ReactDnDMultiBackend.Backend.HTML5 or ReactDnDMultiBackend.Backend.Touch

Concerning the Preview class, it is created using the following snippet:

  var MultiBackend = require('react-dnd-multi-backend');
  ...
  <MultiBackend.Preview generator={this.generatePreview} />

You must pass a function as the generator prop which takes 3 arguments:

  • type: the type of the item (monitor.getItemType())
  • item: the item (monitor.getItem())
  • style: an object representing the style (used for positioning), it should be passed to the style property of your preview component

Note that this component will only be showed while using the Touch backend.

You can see an example here.

Thanks

Thanks to the React DnD HTML5 Backend maintainers which obviously greatly inspired this project.

License

MIT, Copyright (c) 2016-2017 Louis Brunner

Keywords

FAQs

Package last updated on 13 Jan 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc