react-dnd-multi-backend
Advanced tools
Comparing version 3.1.14 to 3.2.0
{ | ||
"name": "react-dnd-multi-backend", | ||
"version": "3.1.14", | ||
"version": "3.2.0", | ||
"description": "Multi Backend system compatible with React DnD", | ||
@@ -20,3 +20,3 @@ "author": "Louis Brunner <louis.brunner.fr@gmail.com> (https://github.com/LouisBrunner)", | ||
"dependencies": { | ||
"dnd-multi-backend": "^3.1.14", | ||
"dnd-multi-backend": "^3.2.0", | ||
"prop-types": "^15.6.2", | ||
@@ -36,4 +36,3 @@ "react-dnd-preview": "^3.1.14" | ||
"react-dnd-touch-backend": "^0.5.2" | ||
}, | ||
"gitHead": "f786fa26bca089a51876236fd08343b3704692ff" | ||
} | ||
} |
@@ -80,3 +80,6 @@ # React DnD Multi Backend [![NPM Version][npm-image]][npm-url] [![dependencies Status][deps-image]][deps-url] [![devDependencies Status][deps-dev-image]][deps-dev-url] | ||
Each backend entry must specify one property: `backend`, containing the class of the Backend to instantiate. | ||
But other options are available: `preview` (a boolean indicating if `Preview` components should be shown) and `transition` (an object returned by the `createTransition` function). | ||
But other options are available: | ||
- `preview` (a boolean indicating if `Preview` components should be shown) | ||
- `transition` (an object returned by the `createTransition` function) | ||
- `skipDispatchOnTransition` (a boolean indicating transition events should not be dispatched to new backend, defaults to `false`. See [note below](#note-on-skipdispatchontransition) for details and use cases.) | ||
@@ -118,3 +121,34 @@ Here is the `HTML5toTouch` pipeline code as an example: | ||
#### Note on `skipDispatchOnTransition` | ||
By default, when an event triggers a transition, `dnd-multi-backend` dispatches a cloned version of the event after setting up the new backend. This allows the newly activated backend to handle the original event. | ||
If your app code or another library has registered event listeners for the same events that are being used for transitions, this duplicate event may cause problems. | ||
You can optionally disable this behavior per backend: | ||
```js | ||
const CustomHTML5toTouch = { | ||
backends: [ | ||
{ | ||
backend: HTML5Backend, | ||
transition: MouseTransition | ||
// by default, will dispatch a duplicate `mousedown` event when this backend is activated | ||
}, | ||
{ | ||
backend: TouchBackend({enableMouseEvents: true}), // Note that you can call your backends with options | ||
preview: true, | ||
transition: TouchTransition, | ||
// will not dispatch a duplicate `touchstart` event when this backend is activated | ||
skipDispatchOnTransition: true | ||
} | ||
] | ||
}; | ||
``` | ||
**WARNING:** if you enable `skipDispatchOnTransition`, the backend transition will happen as expected, but the new backend may not handle the first event! | ||
In this example, the first `touchstart` event would trigger the `TouchBackend` to replace the `HTML5Backend`—but the user would have to start a new touch event for the `TouchBackend` to register a drag. | ||
### Preview | ||
@@ -121,0 +155,0 @@ |
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
17304
223
5
1
Updateddnd-multi-backend@^3.2.0