drag-drop-registry.d.ts 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 { NgZone, OnDestroy } from '@angular/core';
  9. import { Subject } from 'rxjs';
  10. /**
  11. * Service that keeps track of all the drag item and drop container
  12. * instances, and manages global event listeners on the `document`.
  13. * @docs-private
  14. */
  15. export declare class DragDropRegistry<I, C extends {
  16. id: string;
  17. }> implements OnDestroy {
  18. private _ngZone;
  19. private _document;
  20. /** Registered drop container instances. */
  21. private _dropInstances;
  22. /** Registered drag item instances. */
  23. private _dragInstances;
  24. /** Drag item instances that are currently being dragged. */
  25. private _activeDragInstances;
  26. /** Keeps track of the event listeners that we've bound to the `document`. */
  27. private _globalListeners;
  28. /**
  29. * Emits the `touchmove` or `mousemove` events that are dispatched
  30. * while the user is dragging a drag item instance.
  31. */
  32. readonly pointerMove: Subject<TouchEvent | MouseEvent>;
  33. /**
  34. * Emits the `touchend` or `mouseup` events that are dispatched
  35. * while the user is dragging a drag item instance.
  36. */
  37. readonly pointerUp: Subject<TouchEvent | MouseEvent>;
  38. /** Emits when the viewport has been scrolled while the user is dragging an item. */
  39. readonly scroll: Subject<Event>;
  40. constructor(_ngZone: NgZone, _document: any);
  41. /** Adds a drop container to the registry. */
  42. registerDropContainer(drop: C): void;
  43. /** Adds a drag item instance to the registry. */
  44. registerDragItem(drag: I): void;
  45. /** Removes a drop container from the registry. */
  46. removeDropContainer(drop: C): void;
  47. /** Removes a drag item instance from the registry. */
  48. removeDragItem(drag: I): void;
  49. /**
  50. * Starts the dragging sequence for a drag instance.
  51. * @param drag Drag instance which is being dragged.
  52. * @param event Event that initiated the dragging.
  53. */
  54. startDragging(drag: I, event: TouchEvent | MouseEvent): void;
  55. /** Stops dragging a drag item instance. */
  56. stopDragging(drag: I): void;
  57. /** Gets whether a drag item instance is currently being dragged. */
  58. isDragging(drag: I): boolean;
  59. /**
  60. * Gets a drop container by its id.
  61. * @deprecated No longer being used. To be removed.
  62. * @breaking-change 8.0.0
  63. */
  64. getDropContainer(id: string): C | undefined;
  65. ngOnDestroy(): void;
  66. /**
  67. * Event listener that will prevent the default browser action while the user is dragging.
  68. * @param event Event whose default action should be prevented.
  69. */
  70. private _preventDefaultWhileDragging;
  71. /** Clears out the global event listeners from the `document`. */
  72. private _clearGlobalListeners;
  73. }