src/drag-source-specification.ts
The spec passed to SkyhookDndService.
Note the two type parameters. Both must represent plain JS objects.
Item
is the type you return from beginDrag()
, and available in monitor.getItem()
.
Limitations in TypeScript may prevent inferring this in many circumstances,
and it will default to {}
. It is best if you are strong-typing to pass a
type parameter like so:
```typescript
DropResult
is the type you expect a drop target to return from drop()
.
It is the type of the object returned by monitor.getDropResult()
during endDrag()
.
Note that your backend may assign some extra properties. You should define a
DropResult
type that recognises these, such as:
```typescript
Methods |
|
Optional canDrag | ||||||
canDrag(monitor: DragSourceMonitor
|
||||||
Optional. Queries your component to determine whether this source can be dragged. Default returns true; this is often sufficient.
Parameters :
Returns :
boolean
|
Optional endDrag | ||||||
endDrag(monitor: DragSourceMonitor
|
||||||
Optional. Notifies your component when dragging ends. This is a good place to fire actions or modify a component. You will often want to check DragSourceMonitor and DragSourceMonitor for more details.
Parameters :
Returns :
void
|
Optional isDragging | ||||||
isDragging(monitor: DragSourceMonitor
|
||||||
By default, only the drag source that initiated the drag operation is considered to be dragging. You might override this by matching on the DragSourceMonitor.id and your component's id, or similar. Do this if the original component may be unmounted during the dragging and later "resurrected" with a different parent. For example, when moving a card across the lists in a Kanban board, you want it to retain the dragged appearance—even though technically, the component gets unmounted and a different one gets mounted every time you hover over another list. Note: You may not call DragSourceMonitor inside this method. NOTE: runs outside Angular change detection. This is for performance
reasons. You shouldn't be making changes to your component here anyway. If
you do change your component inside this callback, it may not appear
immediately, and if you use
Parameters :
Returns :
boolean
|