angular-skyhook
Go back to angular-skyhook-multi-backend
This package does two things.
First, it re-exports dnd-multi-backend
, react-dnd-touch-backend
and react-dnd-html5-backend
.
Second, it gives you a convenient and easy way to render previews for when the touch backend is in use.
Installation
yarn add angular-skyhook-multi-backend
Then change your SkyhookDndModule
backend to a backendFactory
like so:
;
Normal usage
You will want to render previews. The <skyhook-preview>
component is very helpful.
- Create a
<skyhook-preview>
- Add an
<ng-template>
inside, pulling in the item's type aslet-type
, and the item aslet-item="item"
. - Render whatever you want based on that information.
A suggested arrangement is using an [ngSwitch]
directive on the type, with one *ngSwitchCase
per type.
{{ item | json }} {{ item | json }} ...
If you don't like putting reusable strings directly in templates, then try this:
// item-types.ts;
// your-component.ts;
Using the preview component even in HTML5 mode
Sometimes, it is desirable to render a totally custom drag preview even in desktop browsers. This might be because some browsers only show a small feathered section of a larged dragged element, or just because you want to show something different while an item is in flight. You will need two things:
1. An empty HTML5 drag preview
You can attach an empty image as your drag preview. Simply:
Or:
;// ... ngOnInit
2. Disable the touch-backend-only check in the preview component
Simply pass allBackends as true to the preview.
...
Custom backends and transitions
You can also import anything from dnd-multi-backend
and create your own
transitions. Refer to the original documentation, or simply to the autocomplete
through the re-exported types in this package.
Remember that you will need to create an exported function and pass it as a
backendFactory
if you want to continue using Angular AOT compilation.