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