GithubHelp home page GithubHelp logo

trendingtechnology / react-dnd-touch-backend Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gaearon/react-dnd-touch-backend

0.0 1.0 0.0 170 KB

Touch Backend for react-dnd

License: MIT License

JavaScript 100.00%

react-dnd-touch-backend's Introduction

react logo

react-dnd-touch-backend

npm version Dependency Status devDependency Status gzip size

Touch Backend for react-dnd

Usage

Follow react-dnd docs to setup your app. Then swap out HTML5Backend for TouchBackend as such:

import { default as TouchBackend } from 'react-dnd-touch-backend';
import { DragDropContext } from 'react-dnd';

var YourApp = React.createClass(
  /* ... */

);

module.exports = DragDropContext(TouchBackend)(YourApp);

Tips

Drag Preview

Since native Drag-n-Drop is not currently supported in touch devices. A custom DragPreview is required. Check out the example for a sample implementation.

We might try to build it directly in the Backend itself in the future to compensate for this limitation.

Mouse events support*

You can enable capturing mouse events by configuring your TouchBackend as follows:

DragDropContext(TouchBackend({ enableMouseEvents: true }));

NOTE: This is buggy due to the difference in touchstart/touchend event propagation compared to mousedown/mouseup/click. I highly recommend that you use react-dnd-html5-backend instead for a more performant native HTML5 drag capability.*

Examples

The examples folder has a sample integration. In order to build it, run:

npm i && npm run dev

Then navigate to localhost:7789 or (IP Address):7789 in your mobile browser to access the example. Code licensed under the MIT license. See LICENSE file for terms.

react-dnd-touch-backend's People

Contributors

alesjiranek avatar cheryllaird avatar cloudkite avatar danpuzey avatar daugsbi avatar detweilerryan avatar egorvoronov avatar emckay avatar esoman avatar gaearon avatar jacazek avatar jelanithompson avatar joaomosmann avatar jsg2021 avatar longlho avatar lukeapage avatar methyl avatar oliverjash avatar oyshan avatar scottyeck 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.