drag-events.d.ts 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. }
  30. /** Event emitted when the user moves an item into a new drop container. */
  31. export interface CdkDragEnter<T = any, I = T> {
  32. /** Container into which the user has moved the item. */
  33. container: CdkDropList<T>;
  34. /** Item that was removed from the container. */
  35. item: CdkDrag<I>;
  36. /** Index at which the item has entered the container. */
  37. currentIndex: number;
  38. }
  39. /**
  40. * Event emitted when the user removes an item from a
  41. * drop container by moving it into another one.
  42. */
  43. export interface CdkDragExit<T = any, I = T> {
  44. /** Container from which the user has a removed an item. */
  45. container: CdkDropList<T>;
  46. /** Item that was removed from the container. */
  47. item: CdkDrag<I>;
  48. }
  49. /** Event emitted when the user drops a draggable item inside a drop container. */
  50. export interface CdkDragDrop<T, O = T> {
  51. /** Index of the item when it was picked up. */
  52. previousIndex: number;
  53. /** Current index of the item. */
  54. currentIndex: number;
  55. /** Item that is being dropped. */
  56. item: CdkDrag;
  57. /** Container in which the item was dropped. */
  58. container: CdkDropList<T>;
  59. /** Container from which the item was picked up. Can be the same as the `container`. */
  60. previousContainer: CdkDropList<O>;
  61. /** Whether the user's pointer was over the container when the item was dropped. */
  62. isPointerOverContainer: boolean;
  63. /** Distance in pixels that the user has dragged since the drag sequence started. */
  64. distance: {
  65. x: number;
  66. y: number;
  67. };
  68. }
  69. /** Event emitted as the user is dragging a draggable item. */
  70. export interface CdkDragMove<T = any> {
  71. /** Item that is being dragged. */
  72. source: CdkDrag<T>;
  73. /** Position of the user's pointer on the page. */
  74. pointerPosition: {
  75. x: number;
  76. y: number;
  77. };
  78. /** Native event that is causing the dragging. */
  79. event: MouseEvent | TouchEvent;
  80. /** Distance in pixels that the user has dragged since the drag sequence started. */
  81. distance: {
  82. x: number;
  83. y: number;
  84. };
  85. /**
  86. * Indicates the direction in which the user is dragging the element along each axis.
  87. * `1` means that the position is increasing (e.g. the user is moving to the right or downwards),
  88. * whereas `-1` means that it's decreasing (they're moving to the left or upwards). `0` means
  89. * that the position hasn't changed.
  90. */
  91. delta: {
  92. x: -1 | 0 | 1;
  93. y: -1 | 0 | 1;
  94. };
  95. }
  96. /** Event emitted when the user swaps the position of two drag items. */
  97. export interface CdkDragSortEvent<T = any, I = T> {
  98. /** Index from which the item was sorted previously. */
  99. previousIndex: number;
  100. /** Index that the item is currently in. */
  101. currentIndex: number;
  102. /** Container that the item belongs to. */
  103. container: CdkDropList<T>;
  104. /** Item that is being sorted. */
  105. item: CdkDrag<I>;
  106. }