Coder Social home page Coder Social logo

itrelease / react-dnd Goto Github PK

View Code? Open in Web Editor NEW

This project forked from react-dnd/react-dnd

0.0 1.0 0.0 4.89 MB

Flexible HTML5 drag-and-drop mixin for React with full DOM control

Home Page: http://gaearon.github.io/react-dnd

License: MIT License

JavaScript 99.29% HTML 0.13% CSS 0.26% Shell 0.32%

react-dnd's Introduction

React DnD

Join the chat at https://gitter.im/gaearon/react-dnd

Drag and drop for React with full DOM control.

Currently works on top of HTML5 drag-and-drop API, but is moving towards a swappable implementation. Support for touch events is on the roadmap but not currently implemented.

If your company uses React DnD and would like to speed up its development, consider sponsoring the project. I'm currently doing it in the spare time but I would be happy to work on it part-time. Drop me an email at [email protected]. Exciting new features take time.

Philosophy

  • Keep user in full control over rendering;
  • Don't make assumptions about consuming components and their structure;
  • Hide underlying implementation and its quirks;
  • Make 80% easy, 20% possible.

You can also read The Future of Drag and Drop APIs to get an idea of where we're heading.

Live Demo

Demo contains a variety of things you can implement with this library, including:

  • Reacting to hover and dropping;
  • Dropping files;
  • Dragging a box around with snapping;
  • Drawing a custom drag layer;
  • Making cards sortable.

You can do much more, but these examples will help you get started!

Features

  • Emits zero DOM or CSS of its own;
  • Like original HTML5 API, emphasizes dragging data and not just “draggable views”;
  • Support dropping files using the same API;
  • Lets components register as “drag sources” or “drop targets” for different kinds of data;
  • Lets a single component contain several drag sources and drop targets;
  • Lets you provide a custom drag handle, whether DOM subnode or an image;
  • Takes the best from HTML5 API but hides its many quirks:
    • doesn't require you to preventDefault anything to start working;
    • emits enter and leave as you'd expect instead of doing it for every child node;
    • lets you read drag state from render();
    • consistently fires events even if source DOM node was removed;
  • Includes a helper to preload images for drag thumbnails;
  • Lets you render a custom drag layer if you'd rather draw your own drag preview.

Documentation

SemVer

We plan to follow SemVer after 1.0. Before 1.0, minor version bumps may contain breaking changes. Breaking changes will be documented in the Upgrade Guide.

API Reference

Complete API reference is available here.

Walkthrough

If you don't feel comfortable diving into examples source code just yet, you can start with the walkthrough.

Examples

Have you played with live demo yet? Here's the source code for it.

To try it locally, clone the project and run:

npm install
npm start
open http://localhost:8080/

Examples use ES6 syntax via Babel transpiler. You can still use React DnD in an ES5 codebase, but if you copy code from examples, make sure you translate it to ES5 where needed.

Installation

The library can be used separately (dist/ReactDND.min.js) or with a bundler such as Webpack or Browserify.

npm install --save react-dnd

Future Roadmap

  • Touch support;
  • Support for mouse events instead of HTML5 drag-and-drop events;
  • Dragging multiple items at once.

Production Usage

See Also

Thanks

This library is a React port of an API, parts of which were originally written by Andrew Kuznetsov.

A lot of recent progress is due to Nathan Hutchison's contributions and effort.

react-dnd's People

Contributors

alexkuz avatar gaearon avatar gitter-badger avatar gre avatar hakanderyal avatar jgable avatar mistadikay avatar moretti avatar warp avatar

Watchers

 avatar

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.