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 { Directionality } from '@angular/cdk/bidi';
|
---|
9 | import { AfterViewInit, ElementRef, EventEmitter, NgZone, OnDestroy, QueryList, ViewContainerRef, OnChanges, SimpleChanges, ChangeDetectorRef } from '@angular/core';
|
---|
10 | import { BooleanInput } from '@angular/cdk/coercion';
|
---|
11 | import { Observable } from 'rxjs';
|
---|
12 | import { CdkDragDrop, CdkDragEnd, CdkDragEnter, CdkDragExit, CdkDragMove, CdkDragStart, CdkDragRelease } from '../drag-events';
|
---|
13 | import { CdkDragHandle } from './drag-handle';
|
---|
14 | import { CdkDragPlaceholder } from './drag-placeholder';
|
---|
15 | import { CdkDragPreview } from './drag-preview';
|
---|
16 | import { DragRef, Point, PreviewContainer } from '../drag-ref';
|
---|
17 | import { CdkDropListInternal as CdkDropList } from './drop-list';
|
---|
18 | import { DragDrop } from '../drag-drop';
|
---|
19 | import { DragDropConfig, DragStartDelay, DragAxis } from './config';
|
---|
20 | /** Element that can be moved inside a CdkDropList container. */
|
---|
21 | export declare class CdkDrag<T = any> implements AfterViewInit, OnChanges, OnDestroy {
|
---|
22 | /** Element that the draggable is attached to. */
|
---|
23 | element: ElementRef<HTMLElement>;
|
---|
24 | /** Droppable container that the draggable is a part of. */
|
---|
25 | dropContainer: CdkDropList;
|
---|
26 | private _ngZone;
|
---|
27 | private _viewContainerRef;
|
---|
28 | private _dir;
|
---|
29 | private _changeDetectorRef;
|
---|
30 | private _selfHandle?;
|
---|
31 | private _parentDrag?;
|
---|
32 | private readonly _destroyed;
|
---|
33 | private static _dragInstances;
|
---|
34 | /** Reference to the underlying drag instance. */
|
---|
35 | _dragRef: DragRef<CdkDrag<T>>;
|
---|
36 | /** Elements that can be used to drag the draggable item. */
|
---|
37 | _handles: QueryList<CdkDragHandle>;
|
---|
38 | /** Element that will be used as a template to create the draggable item's preview. */
|
---|
39 | _previewTemplate: CdkDragPreview;
|
---|
40 | /** Template for placeholder element rendered to show where a draggable would be dropped. */
|
---|
41 | _placeholderTemplate: CdkDragPlaceholder;
|
---|
42 | /** Arbitrary data to attach to this drag instance. */
|
---|
43 | data: T;
|
---|
44 | /** Locks the position of the dragged element along the specified axis. */
|
---|
45 | lockAxis: DragAxis;
|
---|
46 | /**
|
---|
47 | * Selector that will be used to determine the root draggable element, starting from
|
---|
48 | * the `cdkDrag` element and going up the DOM. Passing an alternate root element is useful
|
---|
49 | * when trying to enable dragging on an element that you might not have access to.
|
---|
50 | */
|
---|
51 | rootElementSelector: string;
|
---|
52 | /**
|
---|
53 | * Node or selector that will be used to determine the element to which the draggable's
|
---|
54 | * position will be constrained. If a string is passed in, it'll be used as a selector that
|
---|
55 | * will be matched starting from the element's parent and going up the DOM until a match
|
---|
56 | * has been found.
|
---|
57 | */
|
---|
58 | boundaryElement: string | ElementRef<HTMLElement> | HTMLElement;
|
---|
59 | /**
|
---|
60 | * Amount of milliseconds to wait after the user has put their
|
---|
61 | * pointer down before starting to drag the element.
|
---|
62 | */
|
---|
63 | dragStartDelay: DragStartDelay;
|
---|
64 | /**
|
---|
65 | * Sets the position of a `CdkDrag` that is outside of a drop container.
|
---|
66 | * Can be used to restore the element's position for a returning user.
|
---|
67 | */
|
---|
68 | freeDragPosition: {
|
---|
69 | x: number;
|
---|
70 | y: number;
|
---|
71 | };
|
---|
72 | /** Whether starting to drag this element is disabled. */
|
---|
73 | get disabled(): boolean;
|
---|
74 | set disabled(value: boolean);
|
---|
75 | private _disabled;
|
---|
76 | /**
|
---|
77 | * Function that can be used to customize the logic of how the position of the drag item
|
---|
78 | * is limited while it's being dragged. Gets called with a point containing the current position
|
---|
79 | * of the user's pointer on the page and should return a point describing where the item should
|
---|
80 | * be rendered.
|
---|
81 | */
|
---|
82 | constrainPosition?: (point: Point, dragRef: DragRef) => Point;
|
---|
83 | /** Class to be added to the preview element. */
|
---|
84 | previewClass: string | string[];
|
---|
85 | /**
|
---|
86 | * Configures the place into which the preview of the item will be inserted. Can be configured
|
---|
87 | * globally through `CDK_DROP_LIST`. Possible values:
|
---|
88 | * - `global` - Preview will be inserted at the bottom of the `<body>`. The advantage is that
|
---|
89 | * you don't have to worry about `overflow: hidden` or `z-index`, but the item won't retain
|
---|
90 | * its inherited styles.
|
---|
91 | * - `parent` - Preview will be inserted into the parent of the drag item. The advantage is that
|
---|
92 | * inherited styles will be preserved, but it may be clipped by `overflow: hidden` or not be
|
---|
93 | * visible due to `z-index`. Furthermore, the preview is going to have an effect over selectors
|
---|
94 | * like `:nth-child` and some flexbox configurations.
|
---|
95 | * - `ElementRef<HTMLElement> | HTMLElement` - Preview will be inserted into a specific element.
|
---|
96 | * Same advantages and disadvantages as `parent`.
|
---|
97 | */
|
---|
98 | previewContainer: PreviewContainer;
|
---|
99 | /** Emits when the user starts dragging the item. */
|
---|
100 | readonly started: EventEmitter<CdkDragStart>;
|
---|
101 | /** Emits when the user has released a drag item, before any animations have started. */
|
---|
102 | readonly released: EventEmitter<CdkDragRelease>;
|
---|
103 | /** Emits when the user stops dragging an item in the container. */
|
---|
104 | readonly ended: EventEmitter<CdkDragEnd>;
|
---|
105 | /** Emits when the user has moved the item into a new container. */
|
---|
106 | readonly entered: EventEmitter<CdkDragEnter<any>>;
|
---|
107 | /** Emits when the user removes the item its container by dragging it into another container. */
|
---|
108 | readonly exited: EventEmitter<CdkDragExit<any>>;
|
---|
109 | /** Emits when the user drops the item inside a container. */
|
---|
110 | readonly dropped: EventEmitter<CdkDragDrop<any>>;
|
---|
111 | /**
|
---|
112 | * Emits as the user is dragging the item. Use with caution,
|
---|
113 | * because this event will fire for every pixel that the user has dragged.
|
---|
114 | */
|
---|
115 | readonly moved: Observable<CdkDragMove<T>>;
|
---|
116 | constructor(
|
---|
117 | /** Element that the draggable is attached to. */
|
---|
118 | element: ElementRef<HTMLElement>,
|
---|
119 | /** Droppable container that the draggable is a part of. */
|
---|
120 | dropContainer: CdkDropList,
|
---|
121 | /**
|
---|
122 | * @deprecated `_document` parameter no longer being used and will be removed.
|
---|
123 | * @breaking-change 12.0.0
|
---|
124 | */
|
---|
125 | _document: any, _ngZone: NgZone, _viewContainerRef: ViewContainerRef, config: DragDropConfig, _dir: Directionality, dragDrop: DragDrop, _changeDetectorRef: ChangeDetectorRef, _selfHandle?: CdkDragHandle | undefined, _parentDrag?: CdkDrag<any> | undefined);
|
---|
126 | /**
|
---|
127 | * Returns the element that is being used as a placeholder
|
---|
128 | * while the current element is being dragged.
|
---|
129 | */
|
---|
130 | getPlaceholderElement(): HTMLElement;
|
---|
131 | /** Returns the root draggable element. */
|
---|
132 | getRootElement(): HTMLElement;
|
---|
133 | /** Resets a standalone drag item to its initial position. */
|
---|
134 | reset(): void;
|
---|
135 | /**
|
---|
136 | * Gets the pixel coordinates of the draggable outside of a drop container.
|
---|
137 | */
|
---|
138 | getFreeDragPosition(): {
|
---|
139 | readonly x: number;
|
---|
140 | readonly y: number;
|
---|
141 | };
|
---|
142 | ngAfterViewInit(): void;
|
---|
143 | ngOnChanges(changes: SimpleChanges): void;
|
---|
144 | ngOnDestroy(): void;
|
---|
145 | /** Syncs the root element with the `DragRef`. */
|
---|
146 | private _updateRootElement;
|
---|
147 | /** Gets the boundary element, based on the `boundaryElement` value. */
|
---|
148 | private _getBoundaryElement;
|
---|
149 | /** Syncs the inputs of the CdkDrag with the options of the underlying DragRef. */
|
---|
150 | private _syncInputs;
|
---|
151 | /** Handles the events from the underlying `DragRef`. */
|
---|
152 | private _handleEvents;
|
---|
153 | /** Assigns the default input values based on a provided config object. */
|
---|
154 | private _assignDefaults;
|
---|
155 | /** Sets up the listener that syncs the handles with the drag ref. */
|
---|
156 | private _setupHandlesListener;
|
---|
157 | static ngAcceptInputType_disabled: BooleanInput;
|
---|
158 | }
|
---|