1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | import { CdkDrag } from './directives/drag';
|
---|
9 | import { CdkDropList } from './directives/drop-list';
|
---|
10 | /** Event emitted when the user starts dragging a draggable. */
|
---|
11 | export interface CdkDragStart<T = any> {
|
---|
12 | /** Draggable that emitted the event. */
|
---|
13 | source: CdkDrag<T>;
|
---|
14 | }
|
---|
15 | /** Event emitted when the user releases an item, before any animations have started. */
|
---|
16 | export interface CdkDragRelease<T = any> {
|
---|
17 | /** Draggable that emitted the event. */
|
---|
18 | source: CdkDrag<T>;
|
---|
19 | }
|
---|
20 | /** Event emitted when the user stops dragging a draggable. */
|
---|
21 | export interface CdkDragEnd<T = any> {
|
---|
22 | /** Draggable that emitted the event. */
|
---|
23 | source: CdkDrag<T>;
|
---|
24 | /** Distance in pixels that the user has dragged since the drag sequence started. */
|
---|
25 | distance: {
|
---|
26 | x: number;
|
---|
27 | y: number;
|
---|
28 | };
|
---|
29 | /** Position where the pointer was when the item was dropped */
|
---|
30 | dropPoint: {
|
---|
31 | x: number;
|
---|
32 | y: number;
|
---|
33 | };
|
---|
34 | }
|
---|
35 | /** Event emitted when the user moves an item into a new drop container. */
|
---|
36 | export interface CdkDragEnter<T = any, I = T> {
|
---|
37 | /** Container into which the user has moved the item. */
|
---|
38 | container: CdkDropList<T>;
|
---|
39 | /** Item that was moved into the container. */
|
---|
40 | item: CdkDrag<I>;
|
---|
41 | /** Index at which the item has entered the container. */
|
---|
42 | currentIndex: number;
|
---|
43 | }
|
---|
44 | /**
|
---|
45 | * Event emitted when the user removes an item from a
|
---|
46 | * drop container by moving it into another one.
|
---|
47 | */
|
---|
48 | export interface CdkDragExit<T = any, I = T> {
|
---|
49 | /** Container from which the user has a removed an item. */
|
---|
50 | container: CdkDropList<T>;
|
---|
51 | /** Item that was removed from the container. */
|
---|
52 | item: CdkDrag<I>;
|
---|
53 | }
|
---|
54 | /** Event emitted when the user drops a draggable item inside a drop container. */
|
---|
55 | export interface CdkDragDrop<T, O = T, I = any> {
|
---|
56 | /** Index of the item when it was picked up. */
|
---|
57 | previousIndex: number;
|
---|
58 | /** Current index of the item. */
|
---|
59 | currentIndex: number;
|
---|
60 | /** Item that is being dropped. */
|
---|
61 | item: CdkDrag<I>;
|
---|
62 | /** Container in which the item was dropped. */
|
---|
63 | container: CdkDropList<T>;
|
---|
64 | /** Container from which the item was picked up. Can be the same as the `container`. */
|
---|
65 | previousContainer: CdkDropList<O>;
|
---|
66 | /** Whether the user's pointer was over the container when the item was dropped. */
|
---|
67 | isPointerOverContainer: boolean;
|
---|
68 | /** Distance in pixels that the user has dragged since the drag sequence started. */
|
---|
69 | distance: {
|
---|
70 | x: number;
|
---|
71 | y: number;
|
---|
72 | };
|
---|
73 | /** Position where the pointer was when the item was dropped */
|
---|
74 | dropPoint: {
|
---|
75 | x: number;
|
---|
76 | y: number;
|
---|
77 | };
|
---|
78 | }
|
---|
79 | /** Event emitted as the user is dragging a draggable item. */
|
---|
80 | export interface CdkDragMove<T = any> {
|
---|
81 | /** Item that is being dragged. */
|
---|
82 | source: CdkDrag<T>;
|
---|
83 | /** Position of the user's pointer on the page. */
|
---|
84 | pointerPosition: {
|
---|
85 | x: number;
|
---|
86 | y: number;
|
---|
87 | };
|
---|
88 | /** Native event that is causing the dragging. */
|
---|
89 | event: MouseEvent | TouchEvent;
|
---|
90 | /** Distance in pixels that the user has dragged since the drag sequence started. */
|
---|
91 | distance: {
|
---|
92 | x: number;
|
---|
93 | y: number;
|
---|
94 | };
|
---|
95 | /**
|
---|
96 | * Indicates the direction in which the user is dragging the element along each axis.
|
---|
97 | * `1` means that the position is increasing (e.g. the user is moving to the right or downwards),
|
---|
98 | * whereas `-1` means that it's decreasing (they're moving to the left or upwards). `0` means
|
---|
99 | * that the position hasn't changed.
|
---|
100 | */
|
---|
101 | delta: {
|
---|
102 | x: -1 | 0 | 1;
|
---|
103 | y: -1 | 0 | 1;
|
---|
104 | };
|
---|
105 | }
|
---|
106 | /** Event emitted when the user swaps the position of two drag items. */
|
---|
107 | export interface CdkDragSortEvent<T = any, I = T> {
|
---|
108 | /** Index from which the item was sorted previously. */
|
---|
109 | previousIndex: number;
|
---|
110 | /** Index that the item is currently in. */
|
---|
111 | currentIndex: number;
|
---|
112 | /** Container that the item belongs to. */
|
---|
113 | container: CdkDropList<T>;
|
---|
114 | /** Item that is being sorted. */
|
---|
115 | item: CdkDrag<I>;
|
---|
116 | }
|
---|