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 { Observable, 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 extends {
|
---|
16 | isDragging(): boolean;
|
---|
17 | }, C> 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 | * Predicate function to check if an item is being dragged. Moved out into a property,
|
---|
30 | * because it'll be called a lot and we don't want to create a new function every time.
|
---|
31 | */
|
---|
32 | private _draggingPredicate;
|
---|
33 | /**
|
---|
34 | * Emits the `touchmove` or `mousemove` events that are dispatched
|
---|
35 | * while the user is dragging a drag item instance.
|
---|
36 | */
|
---|
37 | readonly pointerMove: Subject<TouchEvent | MouseEvent>;
|
---|
38 | /**
|
---|
39 | * Emits the `touchend` or `mouseup` events that are dispatched
|
---|
40 | * while the user is dragging a drag item instance.
|
---|
41 | */
|
---|
42 | readonly pointerUp: Subject<TouchEvent | MouseEvent>;
|
---|
43 | /**
|
---|
44 | * Emits when the viewport has been scrolled while the user is dragging an item.
|
---|
45 | * @deprecated To be turned into a private member. Use the `scrolled` method instead.
|
---|
46 | * @breaking-change 13.0.0
|
---|
47 | */
|
---|
48 | readonly scroll: Subject<Event>;
|
---|
49 | constructor(_ngZone: NgZone, _document: any);
|
---|
50 | /** Adds a drop container to the registry. */
|
---|
51 | registerDropContainer(drop: C): void;
|
---|
52 | /** Adds a drag item instance to the registry. */
|
---|
53 | registerDragItem(drag: I): void;
|
---|
54 | /** Removes a drop container from the registry. */
|
---|
55 | removeDropContainer(drop: C): void;
|
---|
56 | /** Removes a drag item instance from the registry. */
|
---|
57 | removeDragItem(drag: I): void;
|
---|
58 | /**
|
---|
59 | * Starts the dragging sequence for a drag instance.
|
---|
60 | * @param drag Drag instance which is being dragged.
|
---|
61 | * @param event Event that initiated the dragging.
|
---|
62 | */
|
---|
63 | startDragging(drag: I, event: TouchEvent | MouseEvent): void;
|
---|
64 | /** Stops dragging a drag item instance. */
|
---|
65 | stopDragging(drag: I): void;
|
---|
66 | /** Gets whether a drag item instance is currently being dragged. */
|
---|
67 | isDragging(drag: I): boolean;
|
---|
68 | /**
|
---|
69 | * Gets a stream that will emit when any element on the page is scrolled while an item is being
|
---|
70 | * dragged.
|
---|
71 | * @param shadowRoot Optional shadow root that the current dragging sequence started from.
|
---|
72 | * Top-level listeners won't pick up events coming from the shadow DOM so this parameter can
|
---|
73 | * be used to include an additional top-level listener at the shadow root level.
|
---|
74 | */
|
---|
75 | scrolled(shadowRoot?: DocumentOrShadowRoot | null): Observable<Event>;
|
---|
76 | ngOnDestroy(): void;
|
---|
77 | /**
|
---|
78 | * Event listener that will prevent the default browser action while the user is dragging.
|
---|
79 | * @param event Event whose default action should be prevented.
|
---|
80 | */
|
---|
81 | private _preventDefaultWhileDragging;
|
---|
82 | /** Event listener for `touchmove` that is bound even if no dragging is happening. */
|
---|
83 | private _persistentTouchmoveListener;
|
---|
84 | /** Clears out the global event listeners from the `document`. */
|
---|
85 | private _clearGlobalListeners;
|
---|
86 | }
|
---|