@angular/cdk 7.1.1 → 7.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/cdk-a11y.umd.js +5 -1
- package/bundles/cdk-a11y.umd.js.map +1 -1
- package/bundles/cdk-a11y.umd.min.js +1 -1
- package/bundles/cdk-a11y.umd.min.js.map +1 -1
- package/bundles/cdk-drag-drop.umd.js +2030 -1049
- package/bundles/cdk-drag-drop.umd.js.map +1 -1
- package/bundles/cdk-drag-drop.umd.min.js +2 -1
- package/bundles/cdk-drag-drop.umd.min.js.map +1 -1
- package/bundles/cdk-stepper.umd.js +11 -3
- package/bundles/cdk-stepper.umd.js.map +1 -1
- package/bundles/cdk-stepper.umd.min.js +1 -1
- package/bundles/cdk-stepper.umd.min.js.map +1 -1
- package/bundles/cdk-text-field.umd.js +41 -16
- package/bundles/cdk-text-field.umd.js.map +1 -1
- package/bundles/cdk-text-field.umd.min.js +1 -1
- package/bundles/cdk-text-field.umd.min.js.map +1 -1
- package/bundles/cdk-tree.umd.js +1 -1
- package/bundles/cdk-tree.umd.js.map +1 -1
- package/bundles/cdk-tree.umd.min.js +1 -1
- package/bundles/cdk-tree.umd.min.js.map +1 -1
- package/bundles/cdk.umd.js +1 -1
- package/bundles/cdk.umd.js.map +1 -1
- package/bundles/cdk.umd.min.js +1 -1
- package/bundles/cdk.umd.min.js.map +1 -1
- package/drag-drop/typings/{drag-handle.d.ts → directives/drag-handle.d.ts} +0 -0
- package/drag-drop/typings/{drag-placeholder.d.ts → directives/drag-placeholder.d.ts} +0 -0
- package/drag-drop/typings/{drag-preview.d.ts → directives/drag-preview.d.ts} +0 -0
- package/drag-drop/typings/directives/drag.d.ts +108 -0
- package/{typings/esm5/drag-drop → drag-drop/typings/directives}/drop-list-group.d.ts +3 -0
- package/drag-drop/typings/directives/drop-list.d.ts +135 -0
- package/drag-drop/typings/drag-drop-registry.d.ts +8 -3
- package/drag-drop/typings/drag-events.d.ts +14 -7
- package/{typings/esm5/drag-drop/drag.d.ts → drag-drop/typings/drag-ref.d.ts} +143 -82
- package/drag-drop/typings/drop-list-container.d.ts +19 -3
- package/drag-drop/typings/{drop-list.d.ts → drop-list-ref.d.ts} +132 -84
- package/drag-drop/typings/index.d.ts +1 -0
- package/drag-drop/typings/index.metadata.json +1 -1
- package/drag-drop/typings/public-api.d.ts +13 -6
- package/esm2015/a11y.js +5 -1
- package/esm2015/a11y.js.map +1 -1
- package/esm2015/cdk.js +1 -1
- package/esm2015/cdk.js.map +1 -1
- package/esm2015/drag-drop.js +1546 -811
- package/esm2015/drag-drop.js.map +1 -1
- package/esm2015/stepper.js +11 -4
- package/esm2015/stepper.js.map +1 -1
- package/esm2015/text-field.js +28 -16
- package/esm2015/text-field.js.map +1 -1
- package/esm2015/tree.js +2 -2
- package/esm2015/tree.js.map +1 -1
- package/esm5/a11y.es5.js +5 -1
- package/esm5/a11y.es5.js.map +1 -1
- package/esm5/cdk.es5.js +1 -1
- package/esm5/cdk.es5.js.map +1 -1
- package/esm5/drag-drop.es5.js +2025 -1045
- package/esm5/drag-drop.es5.js.map +1 -1
- package/esm5/stepper.es5.js +11 -4
- package/esm5/stepper.es5.js.map +1 -1
- package/esm5/text-field.es5.js +41 -16
- package/esm5/text-field.es5.js.map +1 -1
- package/esm5/tree.es5.js +2 -2
- package/esm5/tree.es5.js.map +1 -1
- package/package.json +4 -4
- package/schematics/ng-generate/drag-drop/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.ts +2 -2
- package/schematics/ng-update/upgrade-data.js +2 -1
- package/schematics/ng-update/upgrade-data.js.map +1 -1
- package/schematics/ng-update/upgrade-rules/index.js +3 -2
- package/schematics/ng-update/upgrade-rules/index.js.map +1 -1
- package/schematics/utils/ast/ng-module-imports.d.ts +1 -1
- package/schematics/utils/ast/ng-module-imports.js +25 -13
- package/schematics/utils/ast/ng-module-imports.js.map +1 -1
- package/schematics/utils/get-project.js +2 -1
- package/schematics/utils/get-project.js.map +1 -1
- package/schematics/utils/parse5-element.js +3 -2
- package/schematics/utils/parse5-element.js.map +1 -1
- package/schematics/utils/project-targets.js +2 -1
- package/schematics/utils/project-targets.js.map +1 -1
- package/schematics/utils/version-agnostic-typescript.js +3 -2
- package/schematics/utils/version-agnostic-typescript.js.map +1 -1
- package/stepper/typings/index.metadata.json +1 -1
- package/stepper/typings/stepper.d.ts +6 -0
- package/text-field/typings/autosize.d.ts +6 -0
- package/text-field/typings/index.metadata.json +1 -1
- package/typings/drag-drop/{drag-handle.d.ts → directives/drag-handle.d.ts} +0 -0
- package/typings/drag-drop/{drag-placeholder.d.ts → directives/drag-placeholder.d.ts} +0 -0
- package/typings/drag-drop/{drag-preview.d.ts → directives/drag-preview.d.ts} +0 -0
- package/typings/drag-drop/directives/drag.d.ts +108 -0
- package/typings/drag-drop/{drop-list-group.d.ts → directives/drop-list-group.d.ts} +3 -0
- package/typings/drag-drop/directives/drop-list.d.ts +135 -0
- package/typings/drag-drop/drag-drop-registry.d.ts +8 -3
- package/typings/drag-drop/drag-events.d.ts +14 -7
- package/typings/drag-drop/{drag.d.ts → drag-ref.d.ts} +143 -82
- package/typings/drag-drop/drop-list-container.d.ts +19 -3
- package/typings/{esm5/drag-drop/drop-list.d.ts → drag-drop/drop-list-ref.d.ts} +132 -84
- package/typings/drag-drop/index.d.ts +1 -0
- package/typings/drag-drop/index.metadata.json +1 -1
- package/typings/drag-drop/public-api.d.ts +13 -6
- package/typings/esm5/drag-drop/{drag-handle.d.ts → directives/drag-handle.d.ts} +0 -0
- package/typings/esm5/drag-drop/{drag-placeholder.d.ts → directives/drag-placeholder.d.ts} +0 -0
- package/typings/esm5/drag-drop/{drag-preview.d.ts → directives/drag-preview.d.ts} +0 -0
- package/typings/esm5/drag-drop/directives/drag.d.ts +108 -0
- package/{drag-drop/typings → typings/esm5/drag-drop/directives}/drop-list-group.d.ts +3 -0
- package/typings/esm5/drag-drop/directives/drop-list.d.ts +135 -0
- package/typings/esm5/drag-drop/drag-drop-registry.d.ts +8 -3
- package/typings/esm5/drag-drop/drag-events.d.ts +14 -7
- package/{drag-drop/typings/drag.d.ts → typings/esm5/drag-drop/drag-ref.d.ts} +143 -82
- package/typings/esm5/drag-drop/drop-list-container.d.ts +19 -3
- package/typings/{drag-drop/drop-list.d.ts → esm5/drag-drop/drop-list-ref.d.ts} +132 -84
- package/typings/esm5/drag-drop/index.d.ts +1 -0
- package/typings/esm5/drag-drop/index.metadata.json +1 -1
- package/typings/esm5/drag-drop/public-api.d.ts +13 -6
- package/typings/esm5/index.metadata.json +1 -1
- package/typings/esm5/stepper/index.metadata.json +1 -1
- package/typings/esm5/stepper/stepper.d.ts +6 -0
- package/typings/esm5/text-field/autosize.d.ts +6 -0
- package/typings/esm5/text-field/index.metadata.json +1 -1
- package/typings/index.metadata.json +1 -1
- package/typings/schematics/utils/ast/ng-module-imports.d.ts +1 -1
- package/typings/stepper/index.metadata.json +1 -1
- package/typings/stepper/stepper.d.ts +6 -0
- package/typings/text-field/autosize.d.ts +6 -0
- package/typings/text-field/index.metadata.json +1 -1
package/esm5/drag-drop.es5.js
CHANGED
|
@@ -5,14 +5,114 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
|
-
import { Injectable, NgZone, Inject, ContentChildren, ElementRef, EventEmitter, forwardRef, Input, Output, Optional, Directive, ChangeDetectorRef, SkipSelf, ContentChild,
|
|
8
|
+
import { InjectionToken, Injectable, NgZone, Inject, NgModule, ContentChildren, ElementRef, EventEmitter, forwardRef, Input, Output, Optional, Directive, ChangeDetectorRef, SkipSelf, ContentChild, ViewContainerRef, TemplateRef, defineInjectable, inject } from '@angular/core';
|
|
9
9
|
import { DOCUMENT } from '@angular/common';
|
|
10
10
|
import { normalizePassiveListenerOptions } from '@angular/cdk/platform';
|
|
11
|
-
import { Subject,
|
|
11
|
+
import { Subject, Subscription, Observable } from 'rxjs';
|
|
12
12
|
import { coerceBooleanProperty, coerceArray } from '@angular/cdk/coercion';
|
|
13
13
|
import { Directionality } from '@angular/cdk/bidi';
|
|
14
14
|
import { ViewportRuler } from '@angular/cdk/scrolling';
|
|
15
|
-
import { startWith, take } from 'rxjs/operators';
|
|
15
|
+
import { startWith, take, map } from 'rxjs/operators';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @fileoverview added by tsickle
|
|
19
|
+
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Injection token that is used to provide a CdkDropList instance to CdkDrag.
|
|
23
|
+
* Used for avoiding circular imports.
|
|
24
|
+
* @type {?}
|
|
25
|
+
*/
|
|
26
|
+
var CDK_DROP_LIST = new InjectionToken('CDK_DROP_LIST');
|
|
27
|
+
/**
|
|
28
|
+
* Injection token that is used to provide a CdkDropList instance to CdkDrag.
|
|
29
|
+
* Used for avoiding circular imports.
|
|
30
|
+
* @deprecated Use `CDK_DROP_LIST` instead.
|
|
31
|
+
* \@breaking-change 8.0.0
|
|
32
|
+
* @type {?}
|
|
33
|
+
*/
|
|
34
|
+
var CDK_DROP_LIST_CONTAINER = CDK_DROP_LIST;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @fileoverview added by tsickle
|
|
38
|
+
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @fileoverview added by tsickle
|
|
43
|
+
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Moves an item one index in an array to another.
|
|
48
|
+
* @template T
|
|
49
|
+
* @param {?} array Array in which to move the item.
|
|
50
|
+
* @param {?} fromIndex Starting index of the item.
|
|
51
|
+
* @param {?} toIndex Index to which the item should be moved.
|
|
52
|
+
* @return {?}
|
|
53
|
+
*/
|
|
54
|
+
function moveItemInArray(array, fromIndex, toIndex) {
|
|
55
|
+
/** @type {?} */
|
|
56
|
+
var from = clamp(fromIndex, array.length - 1);
|
|
57
|
+
/** @type {?} */
|
|
58
|
+
var to = clamp(toIndex, array.length - 1);
|
|
59
|
+
if (from === to) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
/** @type {?} */
|
|
63
|
+
var target = array[from];
|
|
64
|
+
/** @type {?} */
|
|
65
|
+
var delta = to < from ? -1 : 1;
|
|
66
|
+
for (var i = from; i !== to; i += delta) {
|
|
67
|
+
array[i] = array[i + delta];
|
|
68
|
+
}
|
|
69
|
+
array[to] = target;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Moves an item from one array to another.
|
|
73
|
+
* @template T
|
|
74
|
+
* @param {?} currentArray Array from which to transfer the item.
|
|
75
|
+
* @param {?} targetArray Array into which to put the item.
|
|
76
|
+
* @param {?} currentIndex Index of the item in its current array.
|
|
77
|
+
* @param {?} targetIndex Index at which to insert the item.
|
|
78
|
+
* @return {?}
|
|
79
|
+
*/
|
|
80
|
+
function transferArrayItem(currentArray, targetArray, currentIndex, targetIndex) {
|
|
81
|
+
/** @type {?} */
|
|
82
|
+
var from = clamp(currentIndex, currentArray.length - 1);
|
|
83
|
+
/** @type {?} */
|
|
84
|
+
var to = clamp(targetIndex, targetArray.length);
|
|
85
|
+
if (currentArray.length) {
|
|
86
|
+
targetArray.splice(to, 0, currentArray.splice(from, 1)[0]);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Copies an item from one array to another, leaving it in its
|
|
91
|
+
* original position in current array.
|
|
92
|
+
* @template T
|
|
93
|
+
* @param {?} currentArray Array from which to copy the item.
|
|
94
|
+
* @param {?} targetArray Array into which is copy the item.
|
|
95
|
+
* @param {?} currentIndex Index of the item in its current array.
|
|
96
|
+
* @param {?} targetIndex Index at which to insert the item.
|
|
97
|
+
*
|
|
98
|
+
* @return {?}
|
|
99
|
+
*/
|
|
100
|
+
function copyArrayItem(currentArray, targetArray, currentIndex, targetIndex) {
|
|
101
|
+
/** @type {?} */
|
|
102
|
+
var to = clamp(targetIndex, targetArray.length);
|
|
103
|
+
if (currentArray.length) {
|
|
104
|
+
targetArray.splice(to, 0, currentArray[currentIndex]);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Clamps a number between zero and a maximum.
|
|
109
|
+
* @param {?} value
|
|
110
|
+
* @param {?} max
|
|
111
|
+
* @return {?}
|
|
112
|
+
*/
|
|
113
|
+
function clamp(value, max) {
|
|
114
|
+
return Math.max(0, Math.min(max, value));
|
|
115
|
+
}
|
|
16
116
|
|
|
17
117
|
/**
|
|
18
118
|
* @fileoverview added by tsickle
|
|
@@ -66,9 +166,10 @@ var DragDropRegistry = /** @class */ (function () {
|
|
|
66
166
|
*/
|
|
67
167
|
this.pointerUp = new Subject();
|
|
68
168
|
/**
|
|
69
|
-
*
|
|
169
|
+
* Event listener that will prevent the default browser action while the user is dragging.
|
|
170
|
+
* @param event Event whose default action should be prevented.
|
|
70
171
|
*/
|
|
71
|
-
this.
|
|
172
|
+
this._preventDefaultWhileDragging = function (event) {
|
|
72
173
|
if (_this._activeDragInstances.size) {
|
|
73
174
|
event.preventDefault();
|
|
74
175
|
}
|
|
@@ -115,7 +216,7 @@ var DragDropRegistry = /** @class */ (function () {
|
|
|
115
216
|
this._ngZone.runOutsideAngular(function () {
|
|
116
217
|
// The event handler has to be explicitly active,
|
|
117
218
|
// because newer browsers make it passive by default.
|
|
118
|
-
_this._document.addEventListener('touchmove', _this.
|
|
219
|
+
_this._document.addEventListener('touchmove', _this._preventDefaultWhileDragging, activeCapturingEventOptions);
|
|
119
220
|
});
|
|
120
221
|
}
|
|
121
222
|
};
|
|
@@ -148,7 +249,7 @@ var DragDropRegistry = /** @class */ (function () {
|
|
|
148
249
|
this._dragInstances.delete(drag);
|
|
149
250
|
this.stopDragging(drag);
|
|
150
251
|
if (this._dragInstances.size === 0) {
|
|
151
|
-
this._document.removeEventListener('touchmove', this.
|
|
252
|
+
this._document.removeEventListener('touchmove', this._preventDefaultWhileDragging, activeCapturingEventOptions);
|
|
152
253
|
}
|
|
153
254
|
};
|
|
154
255
|
/**
|
|
@@ -183,18 +284,26 @@ var DragDropRegistry = /** @class */ (function () {
|
|
|
183
284
|
// use `preventDefault` to prevent the page from scrolling while the user is dragging.
|
|
184
285
|
this._globalListeners
|
|
185
286
|
.set(moveEvent, {
|
|
186
|
-
handler: function (e) { return _this.pointerMove.next(e); },
|
|
287
|
+
handler: function (e) { return _this.pointerMove.next((/** @type {?} */ (e))); },
|
|
187
288
|
options: activeCapturingEventOptions
|
|
188
289
|
})
|
|
189
290
|
.set(upEvent, {
|
|
190
|
-
handler: function (e) { return _this.pointerUp.next(e); },
|
|
291
|
+
handler: function (e) { return _this.pointerUp.next((/** @type {?} */ (e))); },
|
|
191
292
|
options: true
|
|
293
|
+
})
|
|
294
|
+
// Preventing the default action on `mousemove` isn't enough to disable text selection
|
|
295
|
+
// on Safari so we need to prevent the selection event as well. Alternatively this can
|
|
296
|
+
// be done by setting `user-select: none` on the `body`, however it has causes a style
|
|
297
|
+
// recalculation which can be expensive on pages with a lot of elements.
|
|
298
|
+
.set('selectstart', {
|
|
299
|
+
handler: this._preventDefaultWhileDragging,
|
|
300
|
+
options: activeCapturingEventOptions
|
|
192
301
|
});
|
|
193
302
|
// TODO(crisbeto): prevent mouse wheel scrolling while
|
|
194
303
|
// dragging until we've set up proper scroll handling.
|
|
195
304
|
if (!isTouchEvent) {
|
|
196
305
|
this._globalListeners.set('wheel', {
|
|
197
|
-
handler: this.
|
|
306
|
+
handler: this._preventDefaultWhileDragging,
|
|
198
307
|
options: activeCapturingEventOptions
|
|
199
308
|
});
|
|
200
309
|
}
|
|
@@ -236,14 +345,22 @@ var DragDropRegistry = /** @class */ (function () {
|
|
|
236
345
|
function (drag) {
|
|
237
346
|
return this._activeDragInstances.has(drag);
|
|
238
347
|
};
|
|
239
|
-
/** Gets a drop container by its id. */
|
|
240
348
|
/**
|
|
241
349
|
* Gets a drop container by its id.
|
|
350
|
+
* @deprecated No longer being used. To be removed.
|
|
351
|
+
* @breaking-change 8.0.0
|
|
352
|
+
*/
|
|
353
|
+
/**
|
|
354
|
+
* Gets a drop container by its id.
|
|
355
|
+
* @deprecated No longer being used. To be removed.
|
|
356
|
+
* \@breaking-change 8.0.0
|
|
242
357
|
* @param {?} id
|
|
243
358
|
* @return {?}
|
|
244
359
|
*/
|
|
245
360
|
DragDropRegistry.prototype.getDropContainer = /**
|
|
246
361
|
* Gets a drop container by its id.
|
|
362
|
+
* @deprecated No longer being used. To be removed.
|
|
363
|
+
* \@breaking-change 8.0.0
|
|
247
364
|
* @param {?} id
|
|
248
365
|
* @return {?}
|
|
249
366
|
*/
|
|
@@ -453,17 +570,6 @@ var CdkDragPreview = /** @class */ (function () {
|
|
|
453
570
|
return CdkDragPreview;
|
|
454
571
|
}());
|
|
455
572
|
|
|
456
|
-
/**
|
|
457
|
-
* @fileoverview added by tsickle
|
|
458
|
-
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
459
|
-
*/
|
|
460
|
-
/**
|
|
461
|
-
* Injection token that is used to provide a CdkDropList instance to CdkDrag.
|
|
462
|
-
* Used for avoiding circular imports.
|
|
463
|
-
* @type {?}
|
|
464
|
-
*/
|
|
465
|
-
var CDK_DROP_LIST_CONTAINER = new InjectionToken('CDK_DROP_LIST_CONTAINER');
|
|
466
|
-
|
|
467
573
|
/**
|
|
468
574
|
* @fileoverview added by tsickle
|
|
469
575
|
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
@@ -523,21 +629,6 @@ function parseCssPropertyValue(computedStyle, name) {
|
|
|
523
629
|
* @fileoverview added by tsickle
|
|
524
630
|
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
525
631
|
*/
|
|
526
|
-
/**
|
|
527
|
-
* Injection token that can be used to configure the behavior of `CdkDrag`.
|
|
528
|
-
* @type {?}
|
|
529
|
-
*/
|
|
530
|
-
var CDK_DRAG_CONFIG = new InjectionToken('CDK_DRAG_CONFIG', {
|
|
531
|
-
providedIn: 'root',
|
|
532
|
-
factory: CDK_DRAG_CONFIG_FACTORY
|
|
533
|
-
});
|
|
534
|
-
/**
|
|
535
|
-
* \@docs-private
|
|
536
|
-
* @return {?}
|
|
537
|
-
*/
|
|
538
|
-
function CDK_DRAG_CONFIG_FACTORY() {
|
|
539
|
-
return { dragStartThreshold: 5, pointerDirectionChangeThreshold: 5 };
|
|
540
|
-
}
|
|
541
632
|
/**
|
|
542
633
|
* Options that can be used to bind a passive event listener.
|
|
543
634
|
* @type {?}
|
|
@@ -557,19 +648,25 @@ var activeEventListenerOptions = normalizePassiveListenerOptions({ passive: fals
|
|
|
557
648
|
*/
|
|
558
649
|
var MOUSE_EVENT_IGNORE_TIME = 800;
|
|
559
650
|
/**
|
|
560
|
-
*
|
|
651
|
+
* Reference to a draggable item. Used to manipulate or dispose of the item.
|
|
652
|
+
* \@docs-private
|
|
561
653
|
* @template T
|
|
562
654
|
*/
|
|
563
|
-
var
|
|
564
|
-
|
|
655
|
+
var /**
|
|
656
|
+
* Reference to a draggable item. Used to manipulate or dispose of the item.
|
|
657
|
+
* \@docs-private
|
|
658
|
+
* @template T
|
|
659
|
+
*/
|
|
660
|
+
DragRef = /** @class */ (function () {
|
|
661
|
+
function DragRef(element, _document, _ngZone, _viewContainerRef, _viewportRuler, _dragDropRegistry, _config, dropContainer, _dir) {
|
|
565
662
|
var _this = this;
|
|
566
|
-
this.
|
|
567
|
-
this.dropContainer = dropContainer;
|
|
663
|
+
this._document = _document;
|
|
568
664
|
this._ngZone = _ngZone;
|
|
569
665
|
this._viewContainerRef = _viewContainerRef;
|
|
570
666
|
this._viewportRuler = _viewportRuler;
|
|
571
667
|
this._dragDropRegistry = _dragDropRegistry;
|
|
572
668
|
this._config = _config;
|
|
669
|
+
this.dropContainer = dropContainer;
|
|
573
670
|
this._dir = _dir;
|
|
574
671
|
/**
|
|
575
672
|
* CSS `transform` applied to the element when it isn't being dragged. We need a
|
|
@@ -600,30 +697,46 @@ var CdkDrag = /** @class */ (function () {
|
|
|
600
697
|
*/
|
|
601
698
|
this._pointerUpSubscription = Subscription.EMPTY;
|
|
602
699
|
/**
|
|
603
|
-
*
|
|
700
|
+
* Cached reference to the boundary element.
|
|
604
701
|
*/
|
|
605
|
-
this.
|
|
702
|
+
this._boundaryElement = null;
|
|
703
|
+
/**
|
|
704
|
+
* Elements that can be used to drag the draggable item.
|
|
705
|
+
*/
|
|
706
|
+
this._handles = [];
|
|
707
|
+
/**
|
|
708
|
+
* Whether the native interactions on the element are enabled.
|
|
709
|
+
*/
|
|
710
|
+
this._nativeInteractionsEnabled = true;
|
|
606
711
|
this._disabled = false;
|
|
712
|
+
/**
|
|
713
|
+
* Emits as the drag sequence is being prepared.
|
|
714
|
+
*/
|
|
715
|
+
this.beforeStarted = new Subject();
|
|
607
716
|
/**
|
|
608
717
|
* Emits when the user starts dragging the item.
|
|
609
718
|
*/
|
|
610
|
-
this.started = new
|
|
719
|
+
this.started = new Subject();
|
|
720
|
+
/**
|
|
721
|
+
* Emits when the user has released a drag item, before any animations have started.
|
|
722
|
+
*/
|
|
723
|
+
this.released = new Subject();
|
|
611
724
|
/**
|
|
612
725
|
* Emits when the user stops dragging an item in the container.
|
|
613
726
|
*/
|
|
614
|
-
this.ended = new
|
|
727
|
+
this.ended = new Subject();
|
|
615
728
|
/**
|
|
616
729
|
* Emits when the user has moved the item into a new container.
|
|
617
730
|
*/
|
|
618
|
-
this.entered = new
|
|
731
|
+
this.entered = new Subject();
|
|
619
732
|
/**
|
|
620
733
|
* Emits when the user removes the item its container by dragging it into another container.
|
|
621
734
|
*/
|
|
622
|
-
this.exited = new
|
|
735
|
+
this.exited = new Subject();
|
|
623
736
|
/**
|
|
624
737
|
* Emits when the user drops the item inside a container.
|
|
625
738
|
*/
|
|
626
|
-
this.dropped = new
|
|
739
|
+
this.dropped = new Subject();
|
|
627
740
|
/**
|
|
628
741
|
* Emits as the user is dragging the item. Use with caution,
|
|
629
742
|
* because this event will fire for every pixel that the user has dragged.
|
|
@@ -641,12 +754,11 @@ var CdkDrag = /** @class */ (function () {
|
|
|
641
754
|
* Handler for the `mousedown`/`touchstart` events.
|
|
642
755
|
*/
|
|
643
756
|
this._pointerDown = function (event) {
|
|
644
|
-
|
|
645
|
-
var handles = _this.getChildHandles();
|
|
757
|
+
_this.beforeStarted.next();
|
|
646
758
|
// Delegate the event based on whether it started from a handle or the element itself.
|
|
647
|
-
if (
|
|
759
|
+
if (_this._handles.length) {
|
|
648
760
|
/** @type {?} */
|
|
649
|
-
var targetHandle =
|
|
761
|
+
var targetHandle = _this._handles.find(function (handle) {
|
|
650
762
|
/** @type {?} */
|
|
651
763
|
var element = handle.element.nativeElement;
|
|
652
764
|
/** @type {?} */
|
|
@@ -665,9 +777,9 @@ var CdkDrag = /** @class */ (function () {
|
|
|
665
777
|
* Handler that is invoked when the user moves their pointer after they've initiated a drag.
|
|
666
778
|
*/
|
|
667
779
|
this._pointerMove = function (event) {
|
|
668
|
-
/** @type {?} */
|
|
669
|
-
var pointerPosition = _this._getConstrainedPointerPosition(event);
|
|
670
780
|
if (!_this._hasStartedDragging) {
|
|
781
|
+
/** @type {?} */
|
|
782
|
+
var pointerPosition = _this._getPointerPositionOnPage(event);
|
|
671
783
|
/** @type {?} */
|
|
672
784
|
var distanceX = Math.abs(pointerPosition.x - _this._pickupPositionOnPage.x);
|
|
673
785
|
/** @type {?} */
|
|
@@ -682,19 +794,29 @@ var CdkDrag = /** @class */ (function () {
|
|
|
682
794
|
}
|
|
683
795
|
return;
|
|
684
796
|
}
|
|
797
|
+
// We only need the preview dimensions if we have a boundary element.
|
|
798
|
+
if (_this._boundaryElement) {
|
|
799
|
+
// Cache the preview element rect if we haven't cached it already or if
|
|
800
|
+
// we cached it too early before the element dimensions were computed.
|
|
801
|
+
if (!_this._previewRect || (!_this._previewRect.width && !_this._previewRect.height)) {
|
|
802
|
+
_this._previewRect = (_this._preview || _this._rootElement).getBoundingClientRect();
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
/** @type {?} */
|
|
806
|
+
var constrainedPointerPosition = _this._getConstrainedPointerPosition(event);
|
|
685
807
|
_this._hasMoved = true;
|
|
686
808
|
event.preventDefault();
|
|
687
|
-
_this._updatePointerDirectionDelta(
|
|
809
|
+
_this._updatePointerDirectionDelta(constrainedPointerPosition);
|
|
688
810
|
if (_this.dropContainer) {
|
|
689
|
-
_this._updateActiveDropContainer(
|
|
811
|
+
_this._updateActiveDropContainer(constrainedPointerPosition);
|
|
690
812
|
}
|
|
691
813
|
else {
|
|
692
814
|
/** @type {?} */
|
|
693
815
|
var activeTransform = _this._activeTransform;
|
|
694
816
|
activeTransform.x =
|
|
695
|
-
|
|
817
|
+
constrainedPointerPosition.x - _this._pickupPositionOnPage.x + _this._passiveTransform.x;
|
|
696
818
|
activeTransform.y =
|
|
697
|
-
|
|
819
|
+
constrainedPointerPosition.y - _this._pickupPositionOnPage.y + _this._passiveTransform.y;
|
|
698
820
|
/** @type {?} */
|
|
699
821
|
var transform = getTransform(activeTransform.x, activeTransform.y);
|
|
700
822
|
// Preserve the previous `transform` value, if there was one.
|
|
@@ -714,7 +836,7 @@ var CdkDrag = /** @class */ (function () {
|
|
|
714
836
|
_this._ngZone.run(function () {
|
|
715
837
|
_this._moveEvents.next({
|
|
716
838
|
source: _this,
|
|
717
|
-
pointerPosition:
|
|
839
|
+
pointerPosition: constrainedPointerPosition,
|
|
718
840
|
event: event,
|
|
719
841
|
delta: _this._pointerDirectionDelta
|
|
720
842
|
});
|
|
@@ -724,41 +846,49 @@ var CdkDrag = /** @class */ (function () {
|
|
|
724
846
|
/**
|
|
725
847
|
* Handler that is invoked when the user lifts their pointer up, after initiating a drag.
|
|
726
848
|
*/
|
|
727
|
-
this._pointerUp = function () {
|
|
728
|
-
|
|
849
|
+
this._pointerUp = function (event) {
|
|
850
|
+
// Note that here we use `isDragging` from the service, rather than from `this`.
|
|
851
|
+
// The difference is that the one from the service reflects whether a dragging sequence
|
|
852
|
+
// has been initiated, whereas the one on `this` includes whether the user has passed
|
|
853
|
+
// the minimum dragging threshold.
|
|
854
|
+
if (!_this._dragDropRegistry.isDragging(_this)) {
|
|
729
855
|
return;
|
|
730
856
|
}
|
|
731
857
|
_this._removeSubscriptions();
|
|
732
858
|
_this._dragDropRegistry.stopDragging(_this);
|
|
859
|
+
if (_this._handles) {
|
|
860
|
+
_this._rootElement.style.webkitTapHighlightColor = _this._rootElementTapHighlight;
|
|
861
|
+
}
|
|
733
862
|
if (!_this._hasStartedDragging) {
|
|
734
863
|
return;
|
|
735
864
|
}
|
|
865
|
+
_this.released.next({ source: _this });
|
|
736
866
|
if (!_this.dropContainer) {
|
|
737
867
|
// Convert the active transform into a passive one. This means that next time
|
|
738
868
|
// the user starts dragging the item, its position will be calculated relatively
|
|
739
869
|
// to the new passive transform.
|
|
740
870
|
_this._passiveTransform.x = _this._activeTransform.x;
|
|
741
871
|
_this._passiveTransform.y = _this._activeTransform.y;
|
|
742
|
-
_this._ngZone.run(function () { return _this.ended.
|
|
872
|
+
_this._ngZone.run(function () { return _this.ended.next({ source: _this }); });
|
|
743
873
|
_this._dragDropRegistry.stopDragging(_this);
|
|
744
874
|
return;
|
|
745
875
|
}
|
|
746
876
|
_this._animatePreviewToPlaceholder().then(function () {
|
|
747
|
-
_this._cleanupDragArtifacts();
|
|
877
|
+
_this._cleanupDragArtifacts(event);
|
|
748
878
|
_this._dragDropRegistry.stopDragging(_this);
|
|
749
879
|
});
|
|
750
880
|
};
|
|
751
|
-
this.
|
|
881
|
+
this.withRootElement(element);
|
|
752
882
|
_dragDropRegistry.registerDragItem(this);
|
|
753
883
|
}
|
|
754
|
-
Object.defineProperty(
|
|
884
|
+
Object.defineProperty(DragRef.prototype, "disabled", {
|
|
755
885
|
/** Whether starting to drag this element is disabled. */
|
|
756
886
|
get: /**
|
|
757
887
|
* Whether starting to drag this element is disabled.
|
|
758
888
|
* @return {?}
|
|
759
889
|
*/
|
|
760
890
|
function () {
|
|
761
|
-
return this._disabled || (this.dropContainer && this.dropContainer.disabled);
|
|
891
|
+
return this._disabled || !!(this.dropContainer && this.dropContainer.disabled);
|
|
762
892
|
},
|
|
763
893
|
set: /**
|
|
764
894
|
* @param {?} value
|
|
@@ -779,7 +909,7 @@ var CdkDrag = /** @class */ (function () {
|
|
|
779
909
|
* while the current element is being dragged.
|
|
780
910
|
* @return {?}
|
|
781
911
|
*/
|
|
782
|
-
|
|
912
|
+
DragRef.prototype.getPlaceholderElement = /**
|
|
783
913
|
* Returns the element that is being used as a placeholder
|
|
784
914
|
* while the current element is being dragged.
|
|
785
915
|
* @return {?}
|
|
@@ -792,173 +922,247 @@ var CdkDrag = /** @class */ (function () {
|
|
|
792
922
|
* Returns the root draggable element.
|
|
793
923
|
* @return {?}
|
|
794
924
|
*/
|
|
795
|
-
|
|
925
|
+
DragRef.prototype.getRootElement = /**
|
|
796
926
|
* Returns the root draggable element.
|
|
797
927
|
* @return {?}
|
|
798
928
|
*/
|
|
799
929
|
function () {
|
|
800
930
|
return this._rootElement;
|
|
801
931
|
};
|
|
802
|
-
/**
|
|
932
|
+
/** Registers the handles that can be used to drag the element. */
|
|
933
|
+
/**
|
|
934
|
+
* Registers the handles that can be used to drag the element.
|
|
935
|
+
* @template THIS
|
|
936
|
+
* @this {THIS}
|
|
937
|
+
* @param {?} handles
|
|
938
|
+
* @return {THIS}
|
|
939
|
+
*/
|
|
940
|
+
DragRef.prototype.withHandles = /**
|
|
941
|
+
* Registers the handles that can be used to drag the element.
|
|
942
|
+
* @template THIS
|
|
943
|
+
* @this {THIS}
|
|
944
|
+
* @param {?} handles
|
|
945
|
+
* @return {THIS}
|
|
946
|
+
*/
|
|
947
|
+
function (handles) {
|
|
948
|
+
// TODO(crisbeto): have this accept HTMLElement[] | ElementRef<HTMLElement>[]
|
|
949
|
+
(/** @type {?} */ (this))._handles = handles;
|
|
950
|
+
handles.forEach(function (handle) { return toggleNativeDragInteractions(handle.element.nativeElement, false); });
|
|
951
|
+
(/** @type {?} */ (this))._toggleNativeDragInteractions();
|
|
952
|
+
return (/** @type {?} */ (this));
|
|
953
|
+
};
|
|
954
|
+
/** Registers the template that should be used for the drag preview. */
|
|
955
|
+
/**
|
|
956
|
+
* Registers the template that should be used for the drag preview.
|
|
957
|
+
* @template THIS
|
|
958
|
+
* @this {THIS}
|
|
959
|
+
* @param {?} template
|
|
960
|
+
* @return {THIS}
|
|
961
|
+
*/
|
|
962
|
+
DragRef.prototype.withPreviewTemplate = /**
|
|
963
|
+
* Registers the template that should be used for the drag preview.
|
|
964
|
+
* @template THIS
|
|
965
|
+
* @this {THIS}
|
|
966
|
+
* @param {?} template
|
|
967
|
+
* @return {THIS}
|
|
968
|
+
*/
|
|
969
|
+
function (template) {
|
|
970
|
+
// TODO(crisbeto): have this accept a TemplateRef
|
|
971
|
+
(/** @type {?} */ (this))._previewTemplate = template;
|
|
972
|
+
return (/** @type {?} */ (this));
|
|
973
|
+
};
|
|
974
|
+
/** Registers the template that should be used for the drag placeholder. */
|
|
975
|
+
/**
|
|
976
|
+
* Registers the template that should be used for the drag placeholder.
|
|
977
|
+
* @template THIS
|
|
978
|
+
* @this {THIS}
|
|
979
|
+
* @param {?} template
|
|
980
|
+
* @return {THIS}
|
|
981
|
+
*/
|
|
982
|
+
DragRef.prototype.withPlaceholderTemplate = /**
|
|
983
|
+
* Registers the template that should be used for the drag placeholder.
|
|
984
|
+
* @template THIS
|
|
985
|
+
* @this {THIS}
|
|
986
|
+
* @param {?} template
|
|
987
|
+
* @return {THIS}
|
|
988
|
+
*/
|
|
989
|
+
function (template) {
|
|
990
|
+
// TODO(crisbeto): have this accept a TemplateRef
|
|
991
|
+
(/** @type {?} */ (this))._placeholderTemplate = template;
|
|
992
|
+
return (/** @type {?} */ (this));
|
|
993
|
+
};
|
|
803
994
|
/**
|
|
804
|
-
*
|
|
805
|
-
*
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
*
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
995
|
+
* Sets an alternate drag root element. The root element is the element that will be moved as
|
|
996
|
+
* the user is dragging. Passing an alternate root element is useful when trying to enable
|
|
997
|
+
* dragging on an element that you might not have access to.
|
|
998
|
+
*/
|
|
999
|
+
/**
|
|
1000
|
+
* Sets an alternate drag root element. The root element is the element that will be moved as
|
|
1001
|
+
* the user is dragging. Passing an alternate root element is useful when trying to enable
|
|
1002
|
+
* dragging on an element that you might not have access to.
|
|
1003
|
+
* @template THIS
|
|
1004
|
+
* @this {THIS}
|
|
1005
|
+
* @param {?} rootElement
|
|
1006
|
+
* @return {THIS}
|
|
1007
|
+
*/
|
|
1008
|
+
DragRef.prototype.withRootElement = /**
|
|
1009
|
+
* Sets an alternate drag root element. The root element is the element that will be moved as
|
|
1010
|
+
* the user is dragging. Passing an alternate root element is useful when trying to enable
|
|
1011
|
+
* dragging on an element that you might not have access to.
|
|
1012
|
+
* @template THIS
|
|
1013
|
+
* @this {THIS}
|
|
1014
|
+
* @param {?} rootElement
|
|
1015
|
+
* @return {THIS}
|
|
1016
|
+
*/
|
|
1017
|
+
function (rootElement) {
|
|
1018
|
+
/** @type {?} */
|
|
1019
|
+
var element = rootElement instanceof ElementRef ? rootElement.nativeElement : rootElement;
|
|
1020
|
+
if (element !== (/** @type {?} */ (this))._rootElement) {
|
|
1021
|
+
if ((/** @type {?} */ (this))._rootElement) {
|
|
1022
|
+
(/** @type {?} */ (this))._removeRootElementListeners((/** @type {?} */ (this))._rootElement);
|
|
1023
|
+
}
|
|
1024
|
+
element.addEventListener('mousedown', (/** @type {?} */ (this))._pointerDown, activeEventListenerOptions);
|
|
1025
|
+
element.addEventListener('touchstart', (/** @type {?} */ (this))._pointerDown, passiveEventListenerOptions);
|
|
1026
|
+
(/** @type {?} */ (this))._rootElement = element;
|
|
1027
|
+
}
|
|
1028
|
+
return (/** @type {?} */ (this));
|
|
815
1029
|
};
|
|
816
1030
|
/**
|
|
817
|
-
*
|
|
1031
|
+
* Element to which the draggable's position will be constrained.
|
|
818
1032
|
*/
|
|
819
|
-
|
|
820
|
-
*
|
|
1033
|
+
/**
|
|
1034
|
+
* Element to which the draggable's position will be constrained.
|
|
1035
|
+
* @template THIS
|
|
1036
|
+
* @this {THIS}
|
|
1037
|
+
* @param {?} boundaryElement
|
|
1038
|
+
* @return {THIS}
|
|
821
1039
|
*/
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
rootElement.addEventListener('mousedown', _this._pointerDown, activeEventListenerOptions);
|
|
834
|
-
rootElement.addEventListener('touchstart', _this._pointerDown, passiveEventListenerOptions);
|
|
835
|
-
_this._handles.changes.pipe(startWith(null)).subscribe(function () {
|
|
836
|
-
return toggleNativeDragInteractions(rootElement, _this.getChildHandles().length > 0);
|
|
837
|
-
});
|
|
838
|
-
});
|
|
1040
|
+
DragRef.prototype.withBoundaryElement = /**
|
|
1041
|
+
* Element to which the draggable's position will be constrained.
|
|
1042
|
+
* @template THIS
|
|
1043
|
+
* @this {THIS}
|
|
1044
|
+
* @param {?} boundaryElement
|
|
1045
|
+
* @return {THIS}
|
|
1046
|
+
*/
|
|
1047
|
+
function (boundaryElement) {
|
|
1048
|
+
(/** @type {?} */ (this))._boundaryElement = boundaryElement instanceof ElementRef ?
|
|
1049
|
+
boundaryElement.nativeElement : boundaryElement;
|
|
1050
|
+
return (/** @type {?} */ (this));
|
|
839
1051
|
};
|
|
1052
|
+
/** Removes the dragging functionality from the DOM element. */
|
|
840
1053
|
/**
|
|
1054
|
+
* Removes the dragging functionality from the DOM element.
|
|
841
1055
|
* @return {?}
|
|
842
1056
|
*/
|
|
843
|
-
|
|
1057
|
+
DragRef.prototype.dispose = /**
|
|
1058
|
+
* Removes the dragging functionality from the DOM element.
|
|
844
1059
|
* @return {?}
|
|
845
1060
|
*/
|
|
846
1061
|
function () {
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
//
|
|
852
|
-
//
|
|
853
|
-
|
|
854
|
-
// Since we move out the element to the end of the body while it's being
|
|
855
|
-
// dragged, we have to make sure that it's removed if it gets destroyed.
|
|
856
|
-
this._removeElement(this._rootElement);
|
|
857
|
-
}
|
|
1062
|
+
this._removeRootElementListeners(this._rootElement);
|
|
1063
|
+
// Do this check before removing from the registry since it'll
|
|
1064
|
+
// stop being considered as dragged once it is removed.
|
|
1065
|
+
if (this.isDragging()) {
|
|
1066
|
+
// Since we move out the element to the end of the body while it's being
|
|
1067
|
+
// dragged, we have to make sure that it's removed if it gets destroyed.
|
|
1068
|
+
removeElement(this._rootElement);
|
|
858
1069
|
}
|
|
859
|
-
this._rootElementInitSubscription.unsubscribe();
|
|
860
1070
|
this._destroyPreview();
|
|
861
1071
|
this._destroyPlaceholder();
|
|
862
|
-
this._nextSibling = null;
|
|
863
1072
|
this._dragDropRegistry.removeDragItem(this);
|
|
864
1073
|
this._removeSubscriptions();
|
|
1074
|
+
this.beforeStarted.complete();
|
|
1075
|
+
this.started.complete();
|
|
1076
|
+
this.released.complete();
|
|
1077
|
+
this.ended.complete();
|
|
1078
|
+
this.entered.complete();
|
|
1079
|
+
this.exited.complete();
|
|
1080
|
+
this.dropped.complete();
|
|
865
1081
|
this._moveEvents.complete();
|
|
1082
|
+
this._handles = [];
|
|
1083
|
+
this._boundaryElement = this._rootElement = this._placeholderTemplate =
|
|
1084
|
+
this._previewTemplate = this._nextSibling = (/** @type {?} */ (null));
|
|
866
1085
|
};
|
|
867
1086
|
/** Checks whether the element is currently being dragged. */
|
|
868
1087
|
/**
|
|
869
1088
|
* Checks whether the element is currently being dragged.
|
|
870
1089
|
* @return {?}
|
|
871
1090
|
*/
|
|
872
|
-
|
|
1091
|
+
DragRef.prototype.isDragging = /**
|
|
873
1092
|
* Checks whether the element is currently being dragged.
|
|
874
1093
|
* @return {?}
|
|
875
1094
|
*/
|
|
876
1095
|
function () {
|
|
877
|
-
return this._dragDropRegistry.isDragging(this);
|
|
1096
|
+
return this._hasStartedDragging && this._dragDropRegistry.isDragging(this);
|
|
1097
|
+
};
|
|
1098
|
+
/** Resets a standalone drag item to its initial position. */
|
|
1099
|
+
/**
|
|
1100
|
+
* Resets a standalone drag item to its initial position.
|
|
1101
|
+
* @return {?}
|
|
1102
|
+
*/
|
|
1103
|
+
DragRef.prototype.reset = /**
|
|
1104
|
+
* Resets a standalone drag item to its initial position.
|
|
1105
|
+
* @return {?}
|
|
1106
|
+
*/
|
|
1107
|
+
function () {
|
|
1108
|
+
this._rootElement.style.transform = '';
|
|
1109
|
+
this._activeTransform = { x: 0, y: 0 };
|
|
1110
|
+
this._passiveTransform = { x: 0, y: 0 };
|
|
878
1111
|
};
|
|
879
|
-
/**
|
|
1112
|
+
/** Unsubscribes from the global subscriptions. */
|
|
880
1113
|
/**
|
|
881
|
-
*
|
|
1114
|
+
* Unsubscribes from the global subscriptions.
|
|
882
1115
|
* @private
|
|
883
1116
|
* @return {?}
|
|
884
1117
|
*/
|
|
885
|
-
|
|
886
|
-
*
|
|
1118
|
+
DragRef.prototype._removeSubscriptions = /**
|
|
1119
|
+
* Unsubscribes from the global subscriptions.
|
|
887
1120
|
* @private
|
|
888
1121
|
* @return {?}
|
|
889
1122
|
*/
|
|
890
1123
|
function () {
|
|
891
|
-
|
|
892
|
-
|
|
1124
|
+
this._pointerMoveSubscription.unsubscribe();
|
|
1125
|
+
this._pointerUpSubscription.unsubscribe();
|
|
893
1126
|
};
|
|
1127
|
+
/** Destroys the preview element and its ViewRef. */
|
|
894
1128
|
/**
|
|
895
|
-
*
|
|
896
|
-
*
|
|
897
|
-
* @
|
|
898
|
-
|
|
1129
|
+
* Destroys the preview element and its ViewRef.
|
|
1130
|
+
* @private
|
|
1131
|
+
* @return {?}
|
|
1132
|
+
*/
|
|
1133
|
+
DragRef.prototype._destroyPreview = /**
|
|
1134
|
+
* Destroys the preview element and its ViewRef.
|
|
1135
|
+
* @private
|
|
1136
|
+
* @return {?}
|
|
899
1137
|
*/
|
|
1138
|
+
function () {
|
|
1139
|
+
if (this._preview) {
|
|
1140
|
+
removeElement(this._preview);
|
|
1141
|
+
}
|
|
1142
|
+
if (this._previewRef) {
|
|
1143
|
+
this._previewRef.destroy();
|
|
1144
|
+
}
|
|
1145
|
+
this._preview = this._previewRef = (/** @type {?} */ (null));
|
|
1146
|
+
};
|
|
1147
|
+
/** Destroys the placeholder element and its ViewRef. */
|
|
900
1148
|
/**
|
|
901
|
-
*
|
|
902
|
-
* that will be necessary for the dragging sequence.
|
|
1149
|
+
* Destroys the placeholder element and its ViewRef.
|
|
903
1150
|
* @private
|
|
904
|
-
* @param {?} referenceElement Element that started the drag sequence.
|
|
905
|
-
* @param {?} event Browser event object that started the sequence.
|
|
906
1151
|
* @return {?}
|
|
907
1152
|
*/
|
|
908
|
-
|
|
909
|
-
*
|
|
910
|
-
* that will be necessary for the dragging sequence.
|
|
1153
|
+
DragRef.prototype._destroyPlaceholder = /**
|
|
1154
|
+
* Destroys the placeholder element and its ViewRef.
|
|
911
1155
|
* @private
|
|
912
|
-
* @param {?} referenceElement Element that started the drag sequence.
|
|
913
|
-
* @param {?} event Browser event object that started the sequence.
|
|
914
1156
|
* @return {?}
|
|
915
1157
|
*/
|
|
916
|
-
function (
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
// starting another sequence for a draggable parent somewhere up the DOM tree.
|
|
920
|
-
event.stopPropagation();
|
|
921
|
-
/** @type {?} */
|
|
922
|
-
var isDragging = this._isDragging();
|
|
923
|
-
/** @type {?} */
|
|
924
|
-
var isTouchEvent = this._isTouchEvent(event);
|
|
925
|
-
/** @type {?} */
|
|
926
|
-
var isAuxiliaryMouseButton = !isTouchEvent && ((/** @type {?} */ (event))).button !== 0;
|
|
927
|
-
/** @type {?} */
|
|
928
|
-
var isSyntheticEvent = !isTouchEvent && this._lastTouchEventTime &&
|
|
929
|
-
this._lastTouchEventTime + MOUSE_EVENT_IGNORE_TIME > Date.now();
|
|
930
|
-
// If the event started from an element with the native HTML drag&drop, it'll interfere
|
|
931
|
-
// with our own dragging (e.g. `img` tags do it by default). Prevent the default action
|
|
932
|
-
// to stop it from happening. Note that preventing on `dragstart` also seems to work, but
|
|
933
|
-
// it's flaky and it fails if the user drags it away quickly. Also note that we only want
|
|
934
|
-
// to do this for `mousedown` since doing the same for `touchstart` will stop any `click`
|
|
935
|
-
// events from firing on touch devices.
|
|
936
|
-
if (event.target && ((/** @type {?} */ (event.target))).draggable && event.type === 'mousedown') {
|
|
937
|
-
event.preventDefault();
|
|
938
|
-
}
|
|
939
|
-
// Abort if the user is already dragging or is using a mouse button other than the primary one.
|
|
940
|
-
if (isDragging || isAuxiliaryMouseButton || isSyntheticEvent) {
|
|
941
|
-
return;
|
|
1158
|
+
function () {
|
|
1159
|
+
if (this._placeholder) {
|
|
1160
|
+
removeElement(this._placeholder);
|
|
942
1161
|
}
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
if (this._initialTransform == null) {
|
|
946
|
-
this._initialTransform = this._rootElement.style.transform || '';
|
|
1162
|
+
if (this._placeholderRef) {
|
|
1163
|
+
this._placeholderRef.destroy();
|
|
947
1164
|
}
|
|
948
|
-
this.
|
|
949
|
-
this._initialContainer = this.dropContainer;
|
|
950
|
-
this._pointerMoveSubscription = this._dragDropRegistry.pointerMove.subscribe(this._pointerMove);
|
|
951
|
-
this._pointerUpSubscription = this._dragDropRegistry.pointerUp.subscribe(this._pointerUp);
|
|
952
|
-
this._scrollPosition = this._viewportRuler.getViewportScrollPosition();
|
|
953
|
-
// If we have a custom preview template, the element won't be visible anyway so we avoid the
|
|
954
|
-
// extra `getBoundingClientRect` calls and just move the preview next to the cursor.
|
|
955
|
-
this._pickupPositionInElement = this._previewTemplate ? { x: 0, y: 0 } :
|
|
956
|
-
this._getPointerPositionInElement(referenceElement, event);
|
|
957
|
-
/** @type {?} */
|
|
958
|
-
var pointerPosition = this._pickupPositionOnPage = this._getPointerPositionOnPage(event);
|
|
959
|
-
this._pointerDirectionDelta = { x: 0, y: 0 };
|
|
960
|
-
this._pointerPositionAtLastDirectionChange = { x: pointerPosition.x, y: pointerPosition.y };
|
|
961
|
-
this._dragDropRegistry.startDragging(this, event);
|
|
1165
|
+
this._placeholder = this._placeholderRef = (/** @type {?} */ (null));
|
|
962
1166
|
};
|
|
963
1167
|
/** Starts the dragging sequence. */
|
|
964
1168
|
/**
|
|
@@ -967,7 +1171,7 @@ var CdkDrag = /** @class */ (function () {
|
|
|
967
1171
|
* @param {?} event
|
|
968
1172
|
* @return {?}
|
|
969
1173
|
*/
|
|
970
|
-
|
|
1174
|
+
DragRef.prototype._startDragSequence = /**
|
|
971
1175
|
* Starts the dragging sequence.
|
|
972
1176
|
* @private
|
|
973
1177
|
* @param {?} event
|
|
@@ -975,8 +1179,8 @@ var CdkDrag = /** @class */ (function () {
|
|
|
975
1179
|
*/
|
|
976
1180
|
function (event) {
|
|
977
1181
|
// Emit the event on the item before the one on the container.
|
|
978
|
-
this.started.
|
|
979
|
-
if (
|
|
1182
|
+
this.started.next({ source: this });
|
|
1183
|
+
if (isTouchEvent(event)) {
|
|
980
1184
|
this._lastTouchEventTime = Date.now();
|
|
981
1185
|
}
|
|
982
1186
|
if (this.dropContainer) {
|
|
@@ -998,18 +1202,102 @@ var CdkDrag = /** @class */ (function () {
|
|
|
998
1202
|
this.dropContainer.start();
|
|
999
1203
|
}
|
|
1000
1204
|
};
|
|
1205
|
+
/**
|
|
1206
|
+
* Sets up the different variables and subscriptions
|
|
1207
|
+
* that will be necessary for the dragging sequence.
|
|
1208
|
+
* @param referenceElement Element that started the drag sequence.
|
|
1209
|
+
* @param event Browser event object that started the sequence.
|
|
1210
|
+
*/
|
|
1211
|
+
/**
|
|
1212
|
+
* Sets up the different variables and subscriptions
|
|
1213
|
+
* that will be necessary for the dragging sequence.
|
|
1214
|
+
* @private
|
|
1215
|
+
* @param {?} referenceElement Element that started the drag sequence.
|
|
1216
|
+
* @param {?} event Browser event object that started the sequence.
|
|
1217
|
+
* @return {?}
|
|
1218
|
+
*/
|
|
1219
|
+
DragRef.prototype._initializeDragSequence = /**
|
|
1220
|
+
* Sets up the different variables and subscriptions
|
|
1221
|
+
* that will be necessary for the dragging sequence.
|
|
1222
|
+
* @private
|
|
1223
|
+
* @param {?} referenceElement Element that started the drag sequence.
|
|
1224
|
+
* @param {?} event Browser event object that started the sequence.
|
|
1225
|
+
* @return {?}
|
|
1226
|
+
*/
|
|
1227
|
+
function (referenceElement, event) {
|
|
1228
|
+
// Always stop propagation for the event that initializes
|
|
1229
|
+
// the dragging sequence, in order to prevent it from potentially
|
|
1230
|
+
// starting another sequence for a draggable parent somewhere up the DOM tree.
|
|
1231
|
+
event.stopPropagation();
|
|
1232
|
+
/** @type {?} */
|
|
1233
|
+
var isDragging = this.isDragging();
|
|
1234
|
+
/** @type {?} */
|
|
1235
|
+
var isTouchSequence = isTouchEvent(event);
|
|
1236
|
+
/** @type {?} */
|
|
1237
|
+
var isAuxiliaryMouseButton = !isTouchSequence && ((/** @type {?} */ (event))).button !== 0;
|
|
1238
|
+
/** @type {?} */
|
|
1239
|
+
var rootElement = this._rootElement;
|
|
1240
|
+
/** @type {?} */
|
|
1241
|
+
var isSyntheticEvent = !isTouchSequence && this._lastTouchEventTime &&
|
|
1242
|
+
this._lastTouchEventTime + MOUSE_EVENT_IGNORE_TIME > Date.now();
|
|
1243
|
+
// If the event started from an element with the native HTML drag&drop, it'll interfere
|
|
1244
|
+
// with our own dragging (e.g. `img` tags do it by default). Prevent the default action
|
|
1245
|
+
// to stop it from happening. Note that preventing on `dragstart` also seems to work, but
|
|
1246
|
+
// it's flaky and it fails if the user drags it away quickly. Also note that we only want
|
|
1247
|
+
// to do this for `mousedown` since doing the same for `touchstart` will stop any `click`
|
|
1248
|
+
// events from firing on touch devices.
|
|
1249
|
+
if (event.target && ((/** @type {?} */ (event.target))).draggable && event.type === 'mousedown') {
|
|
1250
|
+
event.preventDefault();
|
|
1251
|
+
}
|
|
1252
|
+
// Abort if the user is already dragging or is using a mouse button other than the primary one.
|
|
1253
|
+
if (isDragging || isAuxiliaryMouseButton || isSyntheticEvent) {
|
|
1254
|
+
return;
|
|
1255
|
+
}
|
|
1256
|
+
// Cache the previous transform amount only after the first drag sequence, because
|
|
1257
|
+
// we don't want our own transforms to stack on top of each other.
|
|
1258
|
+
if (this._initialTransform == null) {
|
|
1259
|
+
this._initialTransform = this._rootElement.style.transform || '';
|
|
1260
|
+
}
|
|
1261
|
+
// If we've got handles, we need to disable the tap highlight on the entire root element,
|
|
1262
|
+
// otherwise iOS will still add it, even though all the drag interactions on the handle
|
|
1263
|
+
// are disabled.
|
|
1264
|
+
if (this._handles.length) {
|
|
1265
|
+
this._rootElementTapHighlight = rootElement.style.webkitTapHighlightColor;
|
|
1266
|
+
rootElement.style.webkitTapHighlightColor = 'transparent';
|
|
1267
|
+
}
|
|
1268
|
+
this._toggleNativeDragInteractions();
|
|
1269
|
+
this._hasStartedDragging = this._hasMoved = false;
|
|
1270
|
+
this._initialContainer = (/** @type {?} */ (this.dropContainer));
|
|
1271
|
+
this._pointerMoveSubscription = this._dragDropRegistry.pointerMove.subscribe(this._pointerMove);
|
|
1272
|
+
this._pointerUpSubscription = this._dragDropRegistry.pointerUp.subscribe(this._pointerUp);
|
|
1273
|
+
this._scrollPosition = this._viewportRuler.getViewportScrollPosition();
|
|
1274
|
+
if (this._boundaryElement) {
|
|
1275
|
+
this._boundaryRect = this._boundaryElement.getBoundingClientRect();
|
|
1276
|
+
}
|
|
1277
|
+
// If we have a custom preview template, the element won't be visible anyway so we avoid the
|
|
1278
|
+
// extra `getBoundingClientRect` calls and just move the preview next to the cursor.
|
|
1279
|
+
this._pickupPositionInElement = this._previewTemplate ? { x: 0, y: 0 } :
|
|
1280
|
+
this._getPointerPositionInElement(referenceElement, event);
|
|
1281
|
+
/** @type {?} */
|
|
1282
|
+
var pointerPosition = this._pickupPositionOnPage = this._getPointerPositionOnPage(event);
|
|
1283
|
+
this._pointerDirectionDelta = { x: 0, y: 0 };
|
|
1284
|
+
this._pointerPositionAtLastDirectionChange = { x: pointerPosition.x, y: pointerPosition.y };
|
|
1285
|
+
this._dragDropRegistry.startDragging(this, event);
|
|
1286
|
+
};
|
|
1001
1287
|
/** Cleans up the DOM artifacts that were added to facilitate the element being dragged. */
|
|
1002
1288
|
/**
|
|
1003
1289
|
* Cleans up the DOM artifacts that were added to facilitate the element being dragged.
|
|
1004
1290
|
* @private
|
|
1291
|
+
* @param {?} event
|
|
1005
1292
|
* @return {?}
|
|
1006
1293
|
*/
|
|
1007
|
-
|
|
1294
|
+
DragRef.prototype._cleanupDragArtifacts = /**
|
|
1008
1295
|
* Cleans up the DOM artifacts that were added to facilitate the element being dragged.
|
|
1009
1296
|
* @private
|
|
1297
|
+
* @param {?} event
|
|
1010
1298
|
* @return {?}
|
|
1011
1299
|
*/
|
|
1012
|
-
function () {
|
|
1300
|
+
function (event) {
|
|
1013
1301
|
var _this = this;
|
|
1014
1302
|
// Restore the element's visibility and insert it at its old position in the DOM.
|
|
1015
1303
|
// It's important that we maintain the position, because moving the element around in the DOM
|
|
@@ -1024,19 +1312,26 @@ var CdkDrag = /** @class */ (function () {
|
|
|
1024
1312
|
}
|
|
1025
1313
|
this._destroyPreview();
|
|
1026
1314
|
this._destroyPlaceholder();
|
|
1315
|
+
this._boundaryRect = this._previewRect = undefined;
|
|
1027
1316
|
// Re-enter the NgZone since we bound `document` events on the outside.
|
|
1028
1317
|
this._ngZone.run(function () {
|
|
1029
1318
|
/** @type {?} */
|
|
1030
|
-
var
|
|
1031
|
-
|
|
1032
|
-
|
|
1319
|
+
var container = (/** @type {?} */ (_this.dropContainer));
|
|
1320
|
+
/** @type {?} */
|
|
1321
|
+
var currentIndex = container.getItemIndex(_this);
|
|
1322
|
+
var _a = _this._getPointerPositionOnPage(event), x = _a.x, y = _a.y;
|
|
1323
|
+
/** @type {?} */
|
|
1324
|
+
var isPointerOverContainer = container._isOverContainer(x, y);
|
|
1325
|
+
_this.ended.next({ source: _this });
|
|
1326
|
+
_this.dropped.next({
|
|
1033
1327
|
item: _this,
|
|
1034
1328
|
currentIndex: currentIndex,
|
|
1035
1329
|
previousIndex: _this._initialContainer.getItemIndex(_this),
|
|
1036
|
-
container:
|
|
1037
|
-
previousContainer: _this._initialContainer
|
|
1330
|
+
container: container,
|
|
1331
|
+
previousContainer: _this._initialContainer,
|
|
1332
|
+
isPointerOverContainer: isPointerOverContainer
|
|
1038
1333
|
});
|
|
1039
|
-
|
|
1334
|
+
container.drop(_this, currentIndex, _this._initialContainer, isPointerOverContainer);
|
|
1040
1335
|
_this.dropContainer = _this._initialContainer;
|
|
1041
1336
|
});
|
|
1042
1337
|
};
|
|
@@ -1051,7 +1346,7 @@ var CdkDrag = /** @class */ (function () {
|
|
|
1051
1346
|
* @param {?} __0
|
|
1052
1347
|
* @return {?}
|
|
1053
1348
|
*/
|
|
1054
|
-
|
|
1349
|
+
DragRef.prototype._updateActiveDropContainer = /**
|
|
1055
1350
|
* Updates the item's position in its drop container, or moves it
|
|
1056
1351
|
* into a new one, depending on its current drag position.
|
|
1057
1352
|
* @private
|
|
@@ -1063,27 +1358,27 @@ var CdkDrag = /** @class */ (function () {
|
|
|
1063
1358
|
var x = _a.x, y = _a.y;
|
|
1064
1359
|
// Drop container that draggable has been moved into.
|
|
1065
1360
|
/** @type {?} */
|
|
1066
|
-
var newContainer = this.dropContainer._getSiblingContainerFromPosition(this, x, y);
|
|
1361
|
+
var newContainer = (/** @type {?} */ (this.dropContainer))._getSiblingContainerFromPosition(this, x, y);
|
|
1067
1362
|
// If we couldn't find a new container to move the item into, and the item has left it's
|
|
1068
|
-
// initial container, check whether the it's
|
|
1069
|
-
//
|
|
1070
|
-
//
|
|
1363
|
+
// initial container, check whether the it's over the initial container. This handles the
|
|
1364
|
+
// case where two containers are connected one way and the user tries to undo dragging an
|
|
1365
|
+
// item into a new container.
|
|
1071
1366
|
if (!newContainer && this.dropContainer !== this._initialContainer &&
|
|
1072
|
-
this._initialContainer.
|
|
1367
|
+
this._initialContainer._isOverContainer(x, y)) {
|
|
1073
1368
|
newContainer = this._initialContainer;
|
|
1074
1369
|
}
|
|
1075
1370
|
if (newContainer) {
|
|
1076
1371
|
this._ngZone.run(function () {
|
|
1077
1372
|
// Notify the old container that the item has left.
|
|
1078
|
-
_this.exited.
|
|
1079
|
-
_this.dropContainer.exit(_this);
|
|
1373
|
+
_this.exited.next({ item: _this, container: (/** @type {?} */ (_this.dropContainer)) });
|
|
1374
|
+
(/** @type {?} */ (_this.dropContainer)).exit(_this);
|
|
1080
1375
|
// Notify the new container that the item has entered.
|
|
1081
|
-
_this.entered.
|
|
1376
|
+
_this.entered.next({ item: _this, container: (/** @type {?} */ (newContainer)) });
|
|
1082
1377
|
_this.dropContainer = (/** @type {?} */ (newContainer));
|
|
1083
1378
|
_this.dropContainer.enter(_this, x, y);
|
|
1084
1379
|
});
|
|
1085
1380
|
}
|
|
1086
|
-
this.dropContainer._sortItem(this, x, y, this._pointerDirectionDelta);
|
|
1381
|
+
(/** @type {?} */ (this.dropContainer))._sortItem(this, x, y, this._pointerDirectionDelta);
|
|
1087
1382
|
this._preview.style.transform =
|
|
1088
1383
|
getTransform(x - this._pickupPositionInElement.x, y - this._pickupPositionInElement.y);
|
|
1089
1384
|
};
|
|
@@ -1097,7 +1392,7 @@ var CdkDrag = /** @class */ (function () {
|
|
|
1097
1392
|
* @private
|
|
1098
1393
|
* @return {?}
|
|
1099
1394
|
*/
|
|
1100
|
-
|
|
1395
|
+
DragRef.prototype._createPreviewElement = /**
|
|
1101
1396
|
* Creates the element that will be rendered next to the user's pointer
|
|
1102
1397
|
* and will be used as a preview of the element that is being dragged.
|
|
1103
1398
|
* @private
|
|
@@ -1125,76 +1420,19 @@ var CdkDrag = /** @class */ (function () {
|
|
|
1125
1420
|
preview.style.transform = getTransform(elementRect.left, elementRect.top);
|
|
1126
1421
|
}
|
|
1127
1422
|
extendStyles(preview.style, {
|
|
1423
|
+
// It's important that we disable the pointer events on the preview, because
|
|
1424
|
+
// it can throw off the `document.elementFromPoint` calls in the `CdkDropList`.
|
|
1425
|
+
pointerEvents: 'none',
|
|
1128
1426
|
position: 'fixed',
|
|
1129
1427
|
top: '0',
|
|
1130
1428
|
left: '0',
|
|
1131
1429
|
zIndex: '1000'
|
|
1132
1430
|
});
|
|
1431
|
+
toggleNativeDragInteractions(preview, false);
|
|
1133
1432
|
preview.classList.add('cdk-drag-preview');
|
|
1134
1433
|
preview.setAttribute('dir', this._dir ? this._dir.value : 'ltr');
|
|
1135
1434
|
return preview;
|
|
1136
1435
|
};
|
|
1137
|
-
/** Creates an element that will be shown instead of the current element while dragging. */
|
|
1138
|
-
/**
|
|
1139
|
-
* Creates an element that will be shown instead of the current element while dragging.
|
|
1140
|
-
* @private
|
|
1141
|
-
* @return {?}
|
|
1142
|
-
*/
|
|
1143
|
-
CdkDrag.prototype._createPlaceholderElement = /**
|
|
1144
|
-
* Creates an element that will be shown instead of the current element while dragging.
|
|
1145
|
-
* @private
|
|
1146
|
-
* @return {?}
|
|
1147
|
-
*/
|
|
1148
|
-
function () {
|
|
1149
|
-
/** @type {?} */
|
|
1150
|
-
var placeholder;
|
|
1151
|
-
if (this._placeholderTemplate) {
|
|
1152
|
-
this._placeholderRef = this._viewContainerRef.createEmbeddedView(this._placeholderTemplate.templateRef, this._placeholderTemplate.data);
|
|
1153
|
-
placeholder = this._placeholderRef.rootNodes[0];
|
|
1154
|
-
}
|
|
1155
|
-
else {
|
|
1156
|
-
placeholder = deepCloneNode(this._rootElement);
|
|
1157
|
-
}
|
|
1158
|
-
placeholder.classList.add('cdk-drag-placeholder');
|
|
1159
|
-
return placeholder;
|
|
1160
|
-
};
|
|
1161
|
-
/**
|
|
1162
|
-
* Figures out the coordinates at which an element was picked up.
|
|
1163
|
-
* @param referenceElement Element that initiated the dragging.
|
|
1164
|
-
* @param event Event that initiated the dragging.
|
|
1165
|
-
*/
|
|
1166
|
-
/**
|
|
1167
|
-
* Figures out the coordinates at which an element was picked up.
|
|
1168
|
-
* @private
|
|
1169
|
-
* @param {?} referenceElement Element that initiated the dragging.
|
|
1170
|
-
* @param {?} event Event that initiated the dragging.
|
|
1171
|
-
* @return {?}
|
|
1172
|
-
*/
|
|
1173
|
-
CdkDrag.prototype._getPointerPositionInElement = /**
|
|
1174
|
-
* Figures out the coordinates at which an element was picked up.
|
|
1175
|
-
* @private
|
|
1176
|
-
* @param {?} referenceElement Element that initiated the dragging.
|
|
1177
|
-
* @param {?} event Event that initiated the dragging.
|
|
1178
|
-
* @return {?}
|
|
1179
|
-
*/
|
|
1180
|
-
function (referenceElement, event) {
|
|
1181
|
-
/** @type {?} */
|
|
1182
|
-
var elementRect = this._rootElement.getBoundingClientRect();
|
|
1183
|
-
/** @type {?} */
|
|
1184
|
-
var handleElement = referenceElement === this._rootElement ? null : referenceElement;
|
|
1185
|
-
/** @type {?} */
|
|
1186
|
-
var referenceRect = handleElement ? handleElement.getBoundingClientRect() : elementRect;
|
|
1187
|
-
/** @type {?} */
|
|
1188
|
-
var point = this._isTouchEvent(event) ? event.targetTouches[0] : event;
|
|
1189
|
-
/** @type {?} */
|
|
1190
|
-
var x = point.pageX - referenceRect.left - this._scrollPosition.left;
|
|
1191
|
-
/** @type {?} */
|
|
1192
|
-
var y = point.pageY - referenceRect.top - this._scrollPosition.top;
|
|
1193
|
-
return {
|
|
1194
|
-
x: referenceRect.left - elementRect.left + x,
|
|
1195
|
-
y: referenceRect.top - elementRect.top + y
|
|
1196
|
-
};
|
|
1197
|
-
};
|
|
1198
1436
|
/**
|
|
1199
1437
|
* Animates the preview element from its current position to the location of the drop placeholder.
|
|
1200
1438
|
* @returns Promise that resolves when the animation completes.
|
|
@@ -1204,7 +1442,7 @@ var CdkDrag = /** @class */ (function () {
|
|
|
1204
1442
|
* @private
|
|
1205
1443
|
* @return {?} Promise that resolves when the animation completes.
|
|
1206
1444
|
*/
|
|
1207
|
-
|
|
1445
|
+
DragRef.prototype._animatePreviewToPlaceholder = /**
|
|
1208
1446
|
* Animates the preview element from its current position to the location of the drop placeholder.
|
|
1209
1447
|
* @private
|
|
1210
1448
|
* @return {?} Promise that resolves when the animation completes.
|
|
@@ -1249,26 +1487,66 @@ var CdkDrag = /** @class */ (function () {
|
|
|
1249
1487
|
});
|
|
1250
1488
|
});
|
|
1251
1489
|
};
|
|
1490
|
+
/** Creates an element that will be shown instead of the current element while dragging. */
|
|
1491
|
+
/**
|
|
1492
|
+
* Creates an element that will be shown instead of the current element while dragging.
|
|
1493
|
+
* @private
|
|
1494
|
+
* @return {?}
|
|
1495
|
+
*/
|
|
1496
|
+
DragRef.prototype._createPlaceholderElement = /**
|
|
1497
|
+
* Creates an element that will be shown instead of the current element while dragging.
|
|
1498
|
+
* @private
|
|
1499
|
+
* @return {?}
|
|
1500
|
+
*/
|
|
1501
|
+
function () {
|
|
1502
|
+
/** @type {?} */
|
|
1503
|
+
var placeholder;
|
|
1504
|
+
if (this._placeholderTemplate) {
|
|
1505
|
+
this._placeholderRef = this._viewContainerRef.createEmbeddedView(this._placeholderTemplate.templateRef, this._placeholderTemplate.data);
|
|
1506
|
+
placeholder = this._placeholderRef.rootNodes[0];
|
|
1507
|
+
}
|
|
1508
|
+
else {
|
|
1509
|
+
placeholder = deepCloneNode(this._rootElement);
|
|
1510
|
+
}
|
|
1511
|
+
placeholder.classList.add('cdk-drag-placeholder');
|
|
1512
|
+
return placeholder;
|
|
1513
|
+
};
|
|
1252
1514
|
/**
|
|
1253
|
-
*
|
|
1254
|
-
* @param
|
|
1515
|
+
* Figures out the coordinates at which an element was picked up.
|
|
1516
|
+
* @param referenceElement Element that initiated the dragging.
|
|
1517
|
+
* @param event Event that initiated the dragging.
|
|
1255
1518
|
*/
|
|
1256
1519
|
/**
|
|
1257
|
-
*
|
|
1520
|
+
* Figures out the coordinates at which an element was picked up.
|
|
1258
1521
|
* @private
|
|
1259
|
-
* @param {?}
|
|
1522
|
+
* @param {?} referenceElement Element that initiated the dragging.
|
|
1523
|
+
* @param {?} event Event that initiated the dragging.
|
|
1260
1524
|
* @return {?}
|
|
1261
1525
|
*/
|
|
1262
|
-
|
|
1263
|
-
*
|
|
1526
|
+
DragRef.prototype._getPointerPositionInElement = /**
|
|
1527
|
+
* Figures out the coordinates at which an element was picked up.
|
|
1264
1528
|
* @private
|
|
1265
|
-
* @param {?}
|
|
1529
|
+
* @param {?} referenceElement Element that initiated the dragging.
|
|
1530
|
+
* @param {?} event Event that initiated the dragging.
|
|
1266
1531
|
* @return {?}
|
|
1267
1532
|
*/
|
|
1268
|
-
function (
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
}
|
|
1533
|
+
function (referenceElement, event) {
|
|
1534
|
+
/** @type {?} */
|
|
1535
|
+
var elementRect = this._rootElement.getBoundingClientRect();
|
|
1536
|
+
/** @type {?} */
|
|
1537
|
+
var handleElement = referenceElement === this._rootElement ? null : referenceElement;
|
|
1538
|
+
/** @type {?} */
|
|
1539
|
+
var referenceRect = handleElement ? handleElement.getBoundingClientRect() : elementRect;
|
|
1540
|
+
/** @type {?} */
|
|
1541
|
+
var point = isTouchEvent(event) ? event.targetTouches[0] : event;
|
|
1542
|
+
/** @type {?} */
|
|
1543
|
+
var x = point.pageX - referenceRect.left - this._scrollPosition.left;
|
|
1544
|
+
/** @type {?} */
|
|
1545
|
+
var y = point.pageY - referenceRect.top - this._scrollPosition.top;
|
|
1546
|
+
return {
|
|
1547
|
+
x: referenceRect.left - elementRect.left + x,
|
|
1548
|
+
y: referenceRect.top - elementRect.top + y
|
|
1549
|
+
};
|
|
1272
1550
|
};
|
|
1273
1551
|
/** Determines the point of the page that was touched by the user. */
|
|
1274
1552
|
/**
|
|
@@ -1277,15 +1555,16 @@ var CdkDrag = /** @class */ (function () {
|
|
|
1277
1555
|
* @param {?} event
|
|
1278
1556
|
* @return {?}
|
|
1279
1557
|
*/
|
|
1280
|
-
|
|
1558
|
+
DragRef.prototype._getPointerPositionOnPage = /**
|
|
1281
1559
|
* Determines the point of the page that was touched by the user.
|
|
1282
1560
|
* @private
|
|
1283
1561
|
* @param {?} event
|
|
1284
1562
|
* @return {?}
|
|
1285
1563
|
*/
|
|
1286
1564
|
function (event) {
|
|
1565
|
+
// `touches` will be empty for start/end events so we have to fall back to `changedTouches`.
|
|
1287
1566
|
/** @type {?} */
|
|
1288
|
-
var point =
|
|
1567
|
+
var point = isTouchEvent(event) ? (event.touches[0] || event.changedTouches[0]) : event;
|
|
1289
1568
|
return {
|
|
1290
1569
|
x: point.pageX - this._scrollPosition.left,
|
|
1291
1570
|
y: point.pageY - this._scrollPosition.top
|
|
@@ -1298,7 +1577,7 @@ var CdkDrag = /** @class */ (function () {
|
|
|
1298
1577
|
* @param {?} event
|
|
1299
1578
|
* @return {?}
|
|
1300
1579
|
*/
|
|
1301
|
-
|
|
1580
|
+
DragRef.prototype._getConstrainedPointerPosition = /**
|
|
1302
1581
|
* Gets the pointer position on the page, accounting for any position constraints.
|
|
1303
1582
|
* @private
|
|
1304
1583
|
* @param {?} event
|
|
@@ -1315,75 +1594,36 @@ var CdkDrag = /** @class */ (function () {
|
|
|
1315
1594
|
else if (this.lockAxis === 'y' || dropContainerLock === 'y') {
|
|
1316
1595
|
point.x = this._pickupPositionOnPage.x;
|
|
1317
1596
|
}
|
|
1597
|
+
if (this._boundaryRect) {
|
|
1598
|
+
var _a = this._pickupPositionInElement, pickupX = _a.x, pickupY = _a.y;
|
|
1599
|
+
/** @type {?} */
|
|
1600
|
+
var boundaryRect = this._boundaryRect;
|
|
1601
|
+
/** @type {?} */
|
|
1602
|
+
var previewRect = (/** @type {?} */ (this._previewRect));
|
|
1603
|
+
/** @type {?} */
|
|
1604
|
+
var minY = boundaryRect.top + pickupY;
|
|
1605
|
+
/** @type {?} */
|
|
1606
|
+
var maxY = boundaryRect.bottom - (previewRect.height - pickupY);
|
|
1607
|
+
/** @type {?} */
|
|
1608
|
+
var minX = boundaryRect.left + pickupX;
|
|
1609
|
+
/** @type {?} */
|
|
1610
|
+
var maxX = boundaryRect.right - (previewRect.width - pickupX);
|
|
1611
|
+
point.x = clamp$1(point.x, minX, maxX);
|
|
1612
|
+
point.y = clamp$1(point.y, minY, maxY);
|
|
1613
|
+
}
|
|
1318
1614
|
return point;
|
|
1319
1615
|
};
|
|
1320
|
-
/**
|
|
1321
|
-
/**
|
|
1322
|
-
* Determines whether an event is a touch event.
|
|
1323
|
-
* @private
|
|
1324
|
-
* @param {?} event
|
|
1325
|
-
* @return {?}
|
|
1326
|
-
*/
|
|
1327
|
-
CdkDrag.prototype._isTouchEvent = /**
|
|
1328
|
-
* Determines whether an event is a touch event.
|
|
1329
|
-
* @private
|
|
1330
|
-
* @param {?} event
|
|
1331
|
-
* @return {?}
|
|
1332
|
-
*/
|
|
1333
|
-
function (event) {
|
|
1334
|
-
return event.type.startsWith('touch');
|
|
1335
|
-
};
|
|
1336
|
-
/** Destroys the preview element and its ViewRef. */
|
|
1616
|
+
/** Updates the current drag delta, based on the user's current pointer position on the page. */
|
|
1337
1617
|
/**
|
|
1338
|
-
*
|
|
1618
|
+
* Updates the current drag delta, based on the user's current pointer position on the page.
|
|
1339
1619
|
* @private
|
|
1620
|
+
* @param {?} pointerPositionOnPage
|
|
1340
1621
|
* @return {?}
|
|
1341
1622
|
*/
|
|
1342
|
-
|
|
1343
|
-
*
|
|
1623
|
+
DragRef.prototype._updatePointerDirectionDelta = /**
|
|
1624
|
+
* Updates the current drag delta, based on the user's current pointer position on the page.
|
|
1344
1625
|
* @private
|
|
1345
|
-
* @
|
|
1346
|
-
*/
|
|
1347
|
-
function () {
|
|
1348
|
-
if (this._preview) {
|
|
1349
|
-
this._removeElement(this._preview);
|
|
1350
|
-
}
|
|
1351
|
-
if (this._previewRef) {
|
|
1352
|
-
this._previewRef.destroy();
|
|
1353
|
-
}
|
|
1354
|
-
this._preview = this._previewRef = (/** @type {?} */ (null));
|
|
1355
|
-
};
|
|
1356
|
-
/** Destroys the placeholder element and its ViewRef. */
|
|
1357
|
-
/**
|
|
1358
|
-
* Destroys the placeholder element and its ViewRef.
|
|
1359
|
-
* @private
|
|
1360
|
-
* @return {?}
|
|
1361
|
-
*/
|
|
1362
|
-
CdkDrag.prototype._destroyPlaceholder = /**
|
|
1363
|
-
* Destroys the placeholder element and its ViewRef.
|
|
1364
|
-
* @private
|
|
1365
|
-
* @return {?}
|
|
1366
|
-
*/
|
|
1367
|
-
function () {
|
|
1368
|
-
if (this._placeholder) {
|
|
1369
|
-
this._removeElement(this._placeholder);
|
|
1370
|
-
}
|
|
1371
|
-
if (this._placeholderRef) {
|
|
1372
|
-
this._placeholderRef.destroy();
|
|
1373
|
-
}
|
|
1374
|
-
this._placeholder = this._placeholderRef = (/** @type {?} */ (null));
|
|
1375
|
-
};
|
|
1376
|
-
/** Updates the current drag delta, based on the user's current pointer position on the page. */
|
|
1377
|
-
/**
|
|
1378
|
-
* Updates the current drag delta, based on the user's current pointer position on the page.
|
|
1379
|
-
* @private
|
|
1380
|
-
* @param {?} pointerPositionOnPage
|
|
1381
|
-
* @return {?}
|
|
1382
|
-
*/
|
|
1383
|
-
CdkDrag.prototype._updatePointerDirectionDelta = /**
|
|
1384
|
-
* Updates the current drag delta, based on the user's current pointer position on the page.
|
|
1385
|
-
* @private
|
|
1386
|
-
* @param {?} pointerPositionOnPage
|
|
1626
|
+
* @param {?} pointerPositionOnPage
|
|
1387
1627
|
* @return {?}
|
|
1388
1628
|
*/
|
|
1389
1629
|
function (pointerPositionOnPage) {
|
|
@@ -1411,91 +1651,45 @@ var CdkDrag = /** @class */ (function () {
|
|
|
1411
1651
|
}
|
|
1412
1652
|
return delta;
|
|
1413
1653
|
};
|
|
1414
|
-
/**
|
|
1654
|
+
/** Toggles the native drag interactions, based on how many handles are registered. */
|
|
1415
1655
|
/**
|
|
1416
|
-
*
|
|
1656
|
+
* Toggles the native drag interactions, based on how many handles are registered.
|
|
1417
1657
|
* @private
|
|
1418
1658
|
* @return {?}
|
|
1419
1659
|
*/
|
|
1420
|
-
|
|
1421
|
-
*
|
|
1660
|
+
DragRef.prototype._toggleNativeDragInteractions = /**
|
|
1661
|
+
* Toggles the native drag interactions, based on how many handles are registered.
|
|
1422
1662
|
* @private
|
|
1423
1663
|
* @return {?}
|
|
1424
1664
|
*/
|
|
1425
1665
|
function () {
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
if (currentElement.matches ? currentElement.matches(selector) :
|
|
1434
|
-
((/** @type {?} */ (currentElement))).msMatchesSelector(selector)) {
|
|
1435
|
-
return currentElement;
|
|
1436
|
-
}
|
|
1437
|
-
currentElement = currentElement.parentElement;
|
|
1438
|
-
}
|
|
1666
|
+
/** @type {?} */
|
|
1667
|
+
var shouldEnable = this._handles.length > 0;
|
|
1668
|
+
// We go through the trouble of keeping track of whether the interactions are enabled,
|
|
1669
|
+
// because we want to avoid triggering style recalculations unless we really have to.
|
|
1670
|
+
if (shouldEnable !== this._nativeInteractionsEnabled) {
|
|
1671
|
+
this._nativeInteractionsEnabled = shouldEnable;
|
|
1672
|
+
toggleNativeDragInteractions(this._rootElement, shouldEnable);
|
|
1439
1673
|
}
|
|
1440
|
-
return this.element.nativeElement;
|
|
1441
1674
|
};
|
|
1442
|
-
/**
|
|
1675
|
+
/** Removes the manually-added event listeners from the root element. */
|
|
1443
1676
|
/**
|
|
1444
|
-
*
|
|
1677
|
+
* Removes the manually-added event listeners from the root element.
|
|
1445
1678
|
* @private
|
|
1679
|
+
* @param {?} element
|
|
1446
1680
|
* @return {?}
|
|
1447
1681
|
*/
|
|
1448
|
-
|
|
1449
|
-
*
|
|
1682
|
+
DragRef.prototype._removeRootElementListeners = /**
|
|
1683
|
+
* Removes the manually-added event listeners from the root element.
|
|
1450
1684
|
* @private
|
|
1685
|
+
* @param {?} element
|
|
1451
1686
|
* @return {?}
|
|
1452
1687
|
*/
|
|
1453
|
-
function () {
|
|
1454
|
-
this.
|
|
1455
|
-
this.
|
|
1456
|
-
};
|
|
1457
|
-
CdkDrag.decorators = [
|
|
1458
|
-
{ type: Directive, args: [{
|
|
1459
|
-
selector: '[cdkDrag]',
|
|
1460
|
-
exportAs: 'cdkDrag',
|
|
1461
|
-
host: {
|
|
1462
|
-
'class': 'cdk-drag',
|
|
1463
|
-
'[class.cdk-drag-dragging]': '_hasStartedDragging && _isDragging()',
|
|
1464
|
-
},
|
|
1465
|
-
providers: [{
|
|
1466
|
-
provide: CDK_DRAG_PARENT,
|
|
1467
|
-
useExisting: CdkDrag
|
|
1468
|
-
}]
|
|
1469
|
-
},] },
|
|
1470
|
-
];
|
|
1471
|
-
/** @nocollapse */
|
|
1472
|
-
CdkDrag.ctorParameters = function () { return [
|
|
1473
|
-
{ type: ElementRef },
|
|
1474
|
-
{ type: undefined, decorators: [{ type: Inject, args: [CDK_DROP_LIST_CONTAINER,] }, { type: Optional }, { type: SkipSelf }] },
|
|
1475
|
-
{ type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] },
|
|
1476
|
-
{ type: NgZone },
|
|
1477
|
-
{ type: ViewContainerRef },
|
|
1478
|
-
{ type: ViewportRuler },
|
|
1479
|
-
{ type: DragDropRegistry },
|
|
1480
|
-
{ type: undefined, decorators: [{ type: Inject, args: [CDK_DRAG_CONFIG,] }] },
|
|
1481
|
-
{ type: Directionality, decorators: [{ type: Optional }] }
|
|
1482
|
-
]; };
|
|
1483
|
-
CdkDrag.propDecorators = {
|
|
1484
|
-
_handles: [{ type: ContentChildren, args: [CdkDragHandle, { descendants: true },] }],
|
|
1485
|
-
_previewTemplate: [{ type: ContentChild, args: [CdkDragPreview,] }],
|
|
1486
|
-
_placeholderTemplate: [{ type: ContentChild, args: [CdkDragPlaceholder,] }],
|
|
1487
|
-
data: [{ type: Input, args: ['cdkDragData',] }],
|
|
1488
|
-
lockAxis: [{ type: Input, args: ['cdkDragLockAxis',] }],
|
|
1489
|
-
rootElementSelector: [{ type: Input, args: ['cdkDragRootElement',] }],
|
|
1490
|
-
disabled: [{ type: Input, args: ['cdkDragDisabled',] }],
|
|
1491
|
-
started: [{ type: Output, args: ['cdkDragStarted',] }],
|
|
1492
|
-
ended: [{ type: Output, args: ['cdkDragEnded',] }],
|
|
1493
|
-
entered: [{ type: Output, args: ['cdkDragEntered',] }],
|
|
1494
|
-
exited: [{ type: Output, args: ['cdkDragExited',] }],
|
|
1495
|
-
dropped: [{ type: Output, args: ['cdkDragDropped',] }],
|
|
1496
|
-
moved: [{ type: Output, args: ['cdkDragMoved',] }]
|
|
1688
|
+
function (element) {
|
|
1689
|
+
element.removeEventListener('mousedown', this._pointerDown, activeEventListenerOptions);
|
|
1690
|
+
element.removeEventListener('touchstart', this._pointerDown, passiveEventListenerOptions);
|
|
1497
1691
|
};
|
|
1498
|
-
return
|
|
1692
|
+
return DragRef;
|
|
1499
1693
|
}());
|
|
1500
1694
|
/**
|
|
1501
1695
|
* Gets a 3d `transform` that can be applied to an element.
|
|
@@ -1505,7 +1699,7 @@ var CdkDrag = /** @class */ (function () {
|
|
|
1505
1699
|
*/
|
|
1506
1700
|
function getTransform(x, y) {
|
|
1507
1701
|
// Round the transforms since some browsers will
|
|
1508
|
-
// blur the elements
|
|
1702
|
+
// blur the elements for sub-pixel transforms.
|
|
1509
1703
|
return "translate3d(" + Math.round(x) + "px, " + Math.round(y) + "px, 0)";
|
|
1510
1704
|
}
|
|
1511
1705
|
/**
|
|
@@ -1520,81 +1714,33 @@ function deepCloneNode(node) {
|
|
|
1520
1714
|
clone.removeAttribute('id');
|
|
1521
1715
|
return clone;
|
|
1522
1716
|
}
|
|
1523
|
-
|
|
1524
|
-
/**
|
|
1525
|
-
* @fileoverview added by tsickle
|
|
1526
|
-
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1527
|
-
*/
|
|
1528
|
-
|
|
1529
|
-
/**
|
|
1530
|
-
* Moves an item one index in an array to another.
|
|
1531
|
-
* @template T
|
|
1532
|
-
* @param {?} array Array in which to move the item.
|
|
1533
|
-
* @param {?} fromIndex Starting index of the item.
|
|
1534
|
-
* @param {?} toIndex Index to which the item should be moved.
|
|
1535
|
-
* @return {?}
|
|
1536
|
-
*/
|
|
1537
|
-
function moveItemInArray(array, fromIndex, toIndex) {
|
|
1538
|
-
/** @type {?} */
|
|
1539
|
-
var from = clamp(fromIndex, array.length - 1);
|
|
1540
|
-
/** @type {?} */
|
|
1541
|
-
var to = clamp(toIndex, array.length - 1);
|
|
1542
|
-
if (from === to) {
|
|
1543
|
-
return;
|
|
1544
|
-
}
|
|
1545
|
-
/** @type {?} */
|
|
1546
|
-
var target = array[from];
|
|
1547
|
-
/** @type {?} */
|
|
1548
|
-
var delta = to < from ? -1 : 1;
|
|
1549
|
-
for (var i = from; i !== to; i += delta) {
|
|
1550
|
-
array[i] = array[i + delta];
|
|
1551
|
-
}
|
|
1552
|
-
array[to] = target;
|
|
1553
|
-
}
|
|
1554
1717
|
/**
|
|
1555
|
-
*
|
|
1556
|
-
* @
|
|
1557
|
-
* @param {?}
|
|
1558
|
-
* @param {?}
|
|
1559
|
-
* @param {?} currentIndex Index of the item in its current array.
|
|
1560
|
-
* @param {?} targetIndex Index at which to insert the item.
|
|
1718
|
+
* Clamps a value between a minimum and a maximum.
|
|
1719
|
+
* @param {?} value
|
|
1720
|
+
* @param {?} min
|
|
1721
|
+
* @param {?} max
|
|
1561
1722
|
* @return {?}
|
|
1562
1723
|
*/
|
|
1563
|
-
function
|
|
1564
|
-
|
|
1565
|
-
var from = clamp(currentIndex, currentArray.length - 1);
|
|
1566
|
-
/** @type {?} */
|
|
1567
|
-
var to = clamp(targetIndex, targetArray.length);
|
|
1568
|
-
if (currentArray.length) {
|
|
1569
|
-
targetArray.splice(to, 0, currentArray.splice(from, 1)[0]);
|
|
1570
|
-
}
|
|
1724
|
+
function clamp$1(value, min, max) {
|
|
1725
|
+
return Math.max(min, Math.min(max, value));
|
|
1571
1726
|
}
|
|
1572
1727
|
/**
|
|
1573
|
-
*
|
|
1574
|
-
*
|
|
1575
|
-
* @template T
|
|
1576
|
-
* @param {?} currentArray Array from which to copy the item.
|
|
1577
|
-
* @param {?} targetArray Array into which is copy the item.
|
|
1578
|
-
* @param {?} currentIndex Index of the item in its current array.
|
|
1579
|
-
* @param {?} targetIndex Index at which to insert the item.
|
|
1580
|
-
*
|
|
1728
|
+
* Helper to remove an element from the DOM and to do all the necessary null checks.
|
|
1729
|
+
* @param {?} element Element to be removed.
|
|
1581
1730
|
* @return {?}
|
|
1582
1731
|
*/
|
|
1583
|
-
function
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
if (currentArray.length) {
|
|
1587
|
-
targetArray.splice(to, 0, currentArray[currentIndex]);
|
|
1732
|
+
function removeElement(element) {
|
|
1733
|
+
if (element && element.parentNode) {
|
|
1734
|
+
element.parentNode.removeChild(element);
|
|
1588
1735
|
}
|
|
1589
1736
|
}
|
|
1590
1737
|
/**
|
|
1591
|
-
*
|
|
1592
|
-
* @param {?}
|
|
1593
|
-
* @param {?} max
|
|
1738
|
+
* Determines whether an event is a touch event.
|
|
1739
|
+
* @param {?} event
|
|
1594
1740
|
* @return {?}
|
|
1595
1741
|
*/
|
|
1596
|
-
function
|
|
1597
|
-
return
|
|
1742
|
+
function isTouchEvent(event) {
|
|
1743
|
+
return event.type.startsWith('touch');
|
|
1598
1744
|
}
|
|
1599
1745
|
|
|
1600
1746
|
/**
|
|
@@ -1602,123 +1748,105 @@ function clamp(value, max) {
|
|
|
1602
1748
|
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1603
1749
|
*/
|
|
1604
1750
|
/**
|
|
1605
|
-
*
|
|
1606
|
-
* elements that are placed inside a `cdkDropListGroup` will be connected to each other
|
|
1607
|
-
* automatically. Can be used as an alternative to the `cdkDropListConnectedTo` input
|
|
1608
|
-
* from `cdkDropList`.
|
|
1609
|
-
* @template T
|
|
1610
|
-
*/
|
|
1611
|
-
var CdkDropListGroup = /** @class */ (function () {
|
|
1612
|
-
function CdkDropListGroup() {
|
|
1613
|
-
/**
|
|
1614
|
-
* Drop lists registered inside the group.
|
|
1615
|
-
*/
|
|
1616
|
-
this._items = new Set();
|
|
1617
|
-
}
|
|
1618
|
-
/**
|
|
1619
|
-
* @return {?}
|
|
1620
|
-
*/
|
|
1621
|
-
CdkDropListGroup.prototype.ngOnDestroy = /**
|
|
1622
|
-
* @return {?}
|
|
1623
|
-
*/
|
|
1624
|
-
function () {
|
|
1625
|
-
this._items.clear();
|
|
1626
|
-
};
|
|
1627
|
-
CdkDropListGroup.decorators = [
|
|
1628
|
-
{ type: Directive, args: [{
|
|
1629
|
-
selector: '[cdkDropListGroup]',
|
|
1630
|
-
exportAs: 'cdkDropListGroup',
|
|
1631
|
-
},] },
|
|
1632
|
-
];
|
|
1633
|
-
return CdkDropListGroup;
|
|
1634
|
-
}());
|
|
1635
|
-
|
|
1636
|
-
/**
|
|
1637
|
-
* @fileoverview added by tsickle
|
|
1638
|
-
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1639
|
-
*/
|
|
1640
|
-
/**
|
|
1641
|
-
* Counter used to generate unique ids for drop zones.
|
|
1751
|
+
* Injection token that can be used to configure the behavior of `CdkDrag`.
|
|
1642
1752
|
* @type {?}
|
|
1643
1753
|
*/
|
|
1644
|
-
var
|
|
1754
|
+
var CDK_DRAG_CONFIG = new InjectionToken('CDK_DRAG_CONFIG', {
|
|
1755
|
+
providedIn: 'root',
|
|
1756
|
+
factory: CDK_DRAG_CONFIG_FACTORY
|
|
1757
|
+
});
|
|
1645
1758
|
/**
|
|
1646
|
-
*
|
|
1647
|
-
*
|
|
1648
|
-
* @type {?}
|
|
1759
|
+
* \@docs-private
|
|
1760
|
+
* @return {?}
|
|
1649
1761
|
*/
|
|
1650
|
-
|
|
1651
|
-
|
|
1762
|
+
function CDK_DRAG_CONFIG_FACTORY() {
|
|
1763
|
+
return { dragStartThreshold: 5, pointerDirectionChangeThreshold: 5 };
|
|
1764
|
+
}
|
|
1652
1765
|
/**
|
|
1653
|
-
*
|
|
1766
|
+
* Element that can be moved inside a CdkDropList container.
|
|
1654
1767
|
* @template T
|
|
1655
1768
|
*/
|
|
1656
|
-
var
|
|
1657
|
-
function
|
|
1769
|
+
var CdkDrag = /** @class */ (function () {
|
|
1770
|
+
function CdkDrag(element, dropContainer, _document, _ngZone, _viewContainerRef, _viewportRuler, _dragDropRegistry, _config, _dir) {
|
|
1771
|
+
var _this = this;
|
|
1658
1772
|
this.element = element;
|
|
1773
|
+
this.dropContainer = dropContainer;
|
|
1774
|
+
this._document = _document;
|
|
1775
|
+
this._ngZone = _ngZone;
|
|
1776
|
+
this._viewContainerRef = _viewContainerRef;
|
|
1777
|
+
this._viewportRuler = _viewportRuler;
|
|
1659
1778
|
this._dragDropRegistry = _dragDropRegistry;
|
|
1660
|
-
this.
|
|
1779
|
+
this._config = _config;
|
|
1661
1780
|
this._dir = _dir;
|
|
1662
|
-
this._group = _group;
|
|
1663
|
-
/**
|
|
1664
|
-
* Other draggable containers that this container is connected to and into which the
|
|
1665
|
-
* container's items can be transferred. Can either be references to other drop containers,
|
|
1666
|
-
* or their unique IDs.
|
|
1667
|
-
*/
|
|
1668
|
-
this.connectedTo = [];
|
|
1669
1781
|
/**
|
|
1670
|
-
*
|
|
1782
|
+
* Subscription to the stream that initializes the root element.
|
|
1671
1783
|
*/
|
|
1672
|
-
this.
|
|
1784
|
+
this._rootElementInitSubscription = Subscription.EMPTY;
|
|
1785
|
+
this._disabled = false;
|
|
1673
1786
|
/**
|
|
1674
|
-
*
|
|
1675
|
-
* in the `connectedTo` of another `CdkDropList`.
|
|
1787
|
+
* Emits when the user starts dragging the item.
|
|
1676
1788
|
*/
|
|
1677
|
-
this.
|
|
1678
|
-
this._disabled = false;
|
|
1789
|
+
this.started = new EventEmitter();
|
|
1679
1790
|
/**
|
|
1680
|
-
*
|
|
1681
|
-
* is allowed to be moved into a drop container.
|
|
1791
|
+
* Emits when the user has released a drag item, before any animations have started.
|
|
1682
1792
|
*/
|
|
1683
|
-
this.
|
|
1793
|
+
this.released = new EventEmitter();
|
|
1684
1794
|
/**
|
|
1685
|
-
* Emits when the user
|
|
1795
|
+
* Emits when the user stops dragging an item in the container.
|
|
1686
1796
|
*/
|
|
1687
|
-
this.
|
|
1797
|
+
this.ended = new EventEmitter();
|
|
1688
1798
|
/**
|
|
1689
|
-
* Emits when the user has moved
|
|
1799
|
+
* Emits when the user has moved the item into a new container.
|
|
1690
1800
|
*/
|
|
1691
1801
|
this.entered = new EventEmitter();
|
|
1692
1802
|
/**
|
|
1693
|
-
* Emits when the user removes
|
|
1694
|
-
* by dragging it into another container.
|
|
1803
|
+
* Emits when the user removes the item its container by dragging it into another container.
|
|
1695
1804
|
*/
|
|
1696
1805
|
this.exited = new EventEmitter();
|
|
1697
1806
|
/**
|
|
1698
|
-
* Emits
|
|
1699
|
-
*/
|
|
1700
|
-
this.sorted = new EventEmitter();
|
|
1701
|
-
/**
|
|
1702
|
-
* Whether an item in the container is being dragged.
|
|
1703
|
-
*/
|
|
1704
|
-
this._dragging = false;
|
|
1705
|
-
/**
|
|
1706
|
-
* Cache of the dimensions of all the items and the sibling containers.
|
|
1807
|
+
* Emits when the user drops the item inside a container.
|
|
1707
1808
|
*/
|
|
1708
|
-
this.
|
|
1809
|
+
this.dropped = new EventEmitter();
|
|
1709
1810
|
/**
|
|
1710
|
-
*
|
|
1711
|
-
*
|
|
1811
|
+
* Emits as the user is dragging the item. Use with caution,
|
|
1812
|
+
* because this event will fire for every pixel that the user has dragged.
|
|
1712
1813
|
*/
|
|
1713
|
-
this.
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1814
|
+
this.moved = Observable.create(function (observer) {
|
|
1815
|
+
/** @type {?} */
|
|
1816
|
+
var subscription = _this._dragRef.moved.pipe(map(function (movedEvent) { return ({
|
|
1817
|
+
source: _this,
|
|
1818
|
+
pointerPosition: movedEvent.pointerPosition,
|
|
1819
|
+
event: movedEvent.event,
|
|
1820
|
+
delta: movedEvent.delta
|
|
1821
|
+
}); })).subscribe(observer);
|
|
1822
|
+
return function () {
|
|
1823
|
+
subscription.unsubscribe();
|
|
1824
|
+
};
|
|
1825
|
+
});
|
|
1826
|
+
/** @type {?} */
|
|
1827
|
+
var ref = this._dragRef = new DragRef(element, this._document, this._ngZone, this._viewContainerRef, this._viewportRuler, this._dragDropRegistry, this._config, this.dropContainer ? this.dropContainer._dropListRef : undefined, this._dir);
|
|
1828
|
+
ref.data = this;
|
|
1829
|
+
ref.beforeStarted.subscribe(function () {
|
|
1830
|
+
if (!ref.isDragging()) {
|
|
1831
|
+
ref.disabled = _this.disabled;
|
|
1832
|
+
ref.lockAxis = _this.lockAxis;
|
|
1833
|
+
ref
|
|
1834
|
+
.withBoundaryElement(_this._getBoundaryElement())
|
|
1835
|
+
.withPlaceholderTemplate(_this._placeholderTemplate)
|
|
1836
|
+
.withPreviewTemplate(_this._previewTemplate);
|
|
1837
|
+
}
|
|
1838
|
+
});
|
|
1839
|
+
this._proxyEvents(ref);
|
|
1840
|
+
}
|
|
1841
|
+
Object.defineProperty(CdkDrag.prototype, "disabled", {
|
|
1842
|
+
/** Whether starting to drag this element is disabled. */
|
|
1717
1843
|
get: /**
|
|
1718
|
-
* Whether starting
|
|
1844
|
+
* Whether starting to drag this element is disabled.
|
|
1719
1845
|
* @return {?}
|
|
1720
1846
|
*/
|
|
1721
|
-
function () {
|
|
1847
|
+
function () {
|
|
1848
|
+
return this._disabled || (this.dropContainer && this.dropContainer.disabled);
|
|
1849
|
+
},
|
|
1722
1850
|
set: /**
|
|
1723
1851
|
* @param {?} value
|
|
1724
1852
|
* @return {?}
|
|
@@ -1730,274 +1858,1025 @@ var CdkDropList = /** @class */ (function () {
|
|
|
1730
1858
|
configurable: true
|
|
1731
1859
|
});
|
|
1732
1860
|
/**
|
|
1861
|
+
* Returns the element that is being used as a placeholder
|
|
1862
|
+
* while the current element is being dragged.
|
|
1863
|
+
*/
|
|
1864
|
+
/**
|
|
1865
|
+
* Returns the element that is being used as a placeholder
|
|
1866
|
+
* while the current element is being dragged.
|
|
1733
1867
|
* @return {?}
|
|
1734
1868
|
*/
|
|
1735
|
-
|
|
1869
|
+
CdkDrag.prototype.getPlaceholderElement = /**
|
|
1870
|
+
* Returns the element that is being used as a placeholder
|
|
1871
|
+
* while the current element is being dragged.
|
|
1736
1872
|
* @return {?}
|
|
1737
1873
|
*/
|
|
1738
1874
|
function () {
|
|
1739
|
-
this.
|
|
1740
|
-
if (this._group) {
|
|
1741
|
-
this._group._items.add(this);
|
|
1742
|
-
}
|
|
1875
|
+
return this._dragRef.getPlaceholderElement();
|
|
1743
1876
|
};
|
|
1877
|
+
/** Returns the root draggable element. */
|
|
1744
1878
|
/**
|
|
1879
|
+
* Returns the root draggable element.
|
|
1745
1880
|
* @return {?}
|
|
1746
1881
|
*/
|
|
1747
|
-
|
|
1882
|
+
CdkDrag.prototype.getRootElement = /**
|
|
1883
|
+
* Returns the root draggable element.
|
|
1748
1884
|
* @return {?}
|
|
1749
1885
|
*/
|
|
1750
1886
|
function () {
|
|
1751
|
-
this.
|
|
1752
|
-
if (this._group) {
|
|
1753
|
-
this._group._items.delete(this);
|
|
1754
|
-
}
|
|
1887
|
+
return this._dragRef.getRootElement();
|
|
1755
1888
|
};
|
|
1756
|
-
/**
|
|
1889
|
+
/** Resets a standalone drag item to its initial position. */
|
|
1757
1890
|
/**
|
|
1758
|
-
*
|
|
1891
|
+
* Resets a standalone drag item to its initial position.
|
|
1759
1892
|
* @return {?}
|
|
1760
1893
|
*/
|
|
1761
|
-
|
|
1762
|
-
*
|
|
1894
|
+
CdkDrag.prototype.reset = /**
|
|
1895
|
+
* Resets a standalone drag item to its initial position.
|
|
1763
1896
|
* @return {?}
|
|
1764
1897
|
*/
|
|
1765
1898
|
function () {
|
|
1766
|
-
this.
|
|
1767
|
-
this._activeDraggables = this._draggables.toArray();
|
|
1768
|
-
this._cachePositions();
|
|
1769
|
-
this._changeDetectorRef.markForCheck();
|
|
1899
|
+
this._dragRef.reset();
|
|
1770
1900
|
};
|
|
1771
1901
|
/**
|
|
1772
|
-
* Drops an item into this container.
|
|
1773
|
-
* @param item Item being dropped into the container.
|
|
1774
|
-
* @param currentIndex Index at which the item should be inserted.
|
|
1775
|
-
* @param previousContainer Container from which the item got dragged in.
|
|
1776
|
-
*/
|
|
1777
|
-
/**
|
|
1778
|
-
* Drops an item into this container.
|
|
1779
|
-
* @param {?} item Item being dropped into the container.
|
|
1780
|
-
* @param {?} currentIndex Index at which the item should be inserted.
|
|
1781
|
-
* @param {?} previousContainer Container from which the item got dragged in.
|
|
1782
1902
|
* @return {?}
|
|
1783
1903
|
*/
|
|
1784
|
-
|
|
1785
|
-
* Drops an item into this container.
|
|
1786
|
-
* @param {?} item Item being dropped into the container.
|
|
1787
|
-
* @param {?} currentIndex Index at which the item should be inserted.
|
|
1788
|
-
* @param {?} previousContainer Container from which the item got dragged in.
|
|
1904
|
+
CdkDrag.prototype.ngAfterViewInit = /**
|
|
1789
1905
|
* @return {?}
|
|
1790
1906
|
*/
|
|
1791
|
-
function (
|
|
1792
|
-
this
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1907
|
+
function () {
|
|
1908
|
+
var _this = this;
|
|
1909
|
+
// We need to wait for the zone to stabilize, in order for the reference
|
|
1910
|
+
// element to be in the proper place in the DOM. This is mostly relevant
|
|
1911
|
+
// for draggable elements inside portals since they get stamped out in
|
|
1912
|
+
// their original DOM position and then they get transferred to the portal.
|
|
1913
|
+
this._rootElementInitSubscription = this._ngZone.onStable.asObservable()
|
|
1914
|
+
.pipe(take(1))
|
|
1915
|
+
.subscribe(function () {
|
|
1916
|
+
/** @type {?} */
|
|
1917
|
+
var rootElement = _this._getRootElement();
|
|
1918
|
+
if (rootElement.nodeType !== _this._document.ELEMENT_NODE) {
|
|
1919
|
+
throw Error("cdkDrag must be attached to an element node. " +
|
|
1920
|
+
("Currently attached to \"" + rootElement.nodeName + "\"."));
|
|
1921
|
+
}
|
|
1922
|
+
_this._dragRef.withRootElement(rootElement);
|
|
1923
|
+
_this._handles.changes
|
|
1924
|
+
.pipe(startWith(_this._handles))
|
|
1925
|
+
.subscribe(function (handleList) {
|
|
1926
|
+
_this._dragRef.withHandles(handleList.filter(function (handle) { return handle._parentDrag === _this; }));
|
|
1927
|
+
});
|
|
1800
1928
|
});
|
|
1801
1929
|
};
|
|
1802
1930
|
/**
|
|
1803
|
-
* Emits an event to indicate that the user moved an item into the container.
|
|
1804
|
-
* @param item Item that was moved into the container.
|
|
1805
|
-
* @param pointerX Position of the item along the X axis.
|
|
1806
|
-
* @param pointerY Position of the item along the Y axis.
|
|
1807
|
-
*/
|
|
1808
|
-
/**
|
|
1809
|
-
* Emits an event to indicate that the user moved an item into the container.
|
|
1810
|
-
* @param {?} item Item that was moved into the container.
|
|
1811
|
-
* @param {?} pointerX Position of the item along the X axis.
|
|
1812
|
-
* @param {?} pointerY Position of the item along the Y axis.
|
|
1813
1931
|
* @return {?}
|
|
1814
1932
|
*/
|
|
1815
|
-
|
|
1816
|
-
* Emits an event to indicate that the user moved an item into the container.
|
|
1817
|
-
* @param {?} item Item that was moved into the container.
|
|
1818
|
-
* @param {?} pointerX Position of the item along the X axis.
|
|
1819
|
-
* @param {?} pointerY Position of the item along the Y axis.
|
|
1933
|
+
CdkDrag.prototype.ngOnDestroy = /**
|
|
1820
1934
|
* @return {?}
|
|
1821
1935
|
*/
|
|
1822
|
-
function (
|
|
1823
|
-
this.
|
|
1824
|
-
this.
|
|
1825
|
-
// We use the coordinates of where the item entered the drop
|
|
1826
|
-
// zone to figure out at which index it should be inserted.
|
|
1827
|
-
/** @type {?} */
|
|
1828
|
-
var newIndex = this._getItemIndexFromPointerPosition(item, pointerX, pointerY);
|
|
1829
|
-
/** @type {?} */
|
|
1830
|
-
var currentIndex = this._activeDraggables.indexOf(item);
|
|
1831
|
-
/** @type {?} */
|
|
1832
|
-
var newPositionReference = this._activeDraggables[newIndex];
|
|
1833
|
-
/** @type {?} */
|
|
1834
|
-
var placeholder = item.getPlaceholderElement();
|
|
1835
|
-
// Since the item may be in the `activeDraggables` already (e.g. if the user dragged it
|
|
1836
|
-
// into another container and back again), we have to ensure that it isn't duplicated.
|
|
1837
|
-
if (currentIndex > -1) {
|
|
1838
|
-
this._activeDraggables.splice(currentIndex, 1);
|
|
1839
|
-
}
|
|
1840
|
-
// Don't use items that are being dragged as a reference, because
|
|
1841
|
-
// their element has been moved down to the bottom of the body.
|
|
1842
|
-
if (newPositionReference && !this._dragDropRegistry.isDragging(newPositionReference)) {
|
|
1843
|
-
/** @type {?} */
|
|
1844
|
-
var element = newPositionReference.getRootElement();
|
|
1845
|
-
(/** @type {?} */ (element.parentElement)).insertBefore(placeholder, element);
|
|
1846
|
-
this._activeDraggables.splice(newIndex, 0, item);
|
|
1847
|
-
}
|
|
1848
|
-
else {
|
|
1849
|
-
this.element.nativeElement.appendChild(placeholder);
|
|
1850
|
-
this._activeDraggables.push(item);
|
|
1851
|
-
}
|
|
1852
|
-
// The transform needs to be cleared so it doesn't throw off the measurements.
|
|
1853
|
-
placeholder.style.transform = '';
|
|
1854
|
-
// Note that the positions were already cached when we called `start` above,
|
|
1855
|
-
// but we need to refresh them since the amount of items has changed.
|
|
1856
|
-
this._cachePositions();
|
|
1936
|
+
function () {
|
|
1937
|
+
this._rootElementInitSubscription.unsubscribe();
|
|
1938
|
+
this._dragRef.dispose();
|
|
1857
1939
|
};
|
|
1940
|
+
/** Gets the root draggable element, based on the `rootElementSelector`. */
|
|
1858
1941
|
/**
|
|
1859
|
-
*
|
|
1860
|
-
* @
|
|
1861
|
-
*/
|
|
1862
|
-
/**
|
|
1863
|
-
* Removes an item from the container after it was dragged into another container by the user.
|
|
1864
|
-
* @param {?} item Item that was dragged out.
|
|
1942
|
+
* Gets the root draggable element, based on the `rootElementSelector`.
|
|
1943
|
+
* @private
|
|
1865
1944
|
* @return {?}
|
|
1866
1945
|
*/
|
|
1867
|
-
|
|
1868
|
-
*
|
|
1869
|
-
* @
|
|
1946
|
+
CdkDrag.prototype._getRootElement = /**
|
|
1947
|
+
* Gets the root draggable element, based on the `rootElementSelector`.
|
|
1948
|
+
* @private
|
|
1870
1949
|
* @return {?}
|
|
1871
1950
|
*/
|
|
1872
|
-
function (
|
|
1873
|
-
|
|
1874
|
-
|
|
1951
|
+
function () {
|
|
1952
|
+
/** @type {?} */
|
|
1953
|
+
var element = this.element.nativeElement;
|
|
1954
|
+
/** @type {?} */
|
|
1955
|
+
var rootElement = this.rootElementSelector ?
|
|
1956
|
+
getClosestMatchingAncestor(element, this.rootElementSelector) : null;
|
|
1957
|
+
return rootElement || element;
|
|
1875
1958
|
};
|
|
1959
|
+
/** Gets the boundary element, based on the `boundaryElementSelector`. */
|
|
1876
1960
|
/**
|
|
1877
|
-
*
|
|
1878
|
-
* @
|
|
1879
|
-
*/
|
|
1880
|
-
/**
|
|
1881
|
-
* Figures out the index of an item in the container.
|
|
1882
|
-
* @param {?} item Item whose index should be determined.
|
|
1961
|
+
* Gets the boundary element, based on the `boundaryElementSelector`.
|
|
1962
|
+
* @private
|
|
1883
1963
|
* @return {?}
|
|
1884
1964
|
*/
|
|
1885
|
-
|
|
1886
|
-
*
|
|
1887
|
-
* @
|
|
1965
|
+
CdkDrag.prototype._getBoundaryElement = /**
|
|
1966
|
+
* Gets the boundary element, based on the `boundaryElementSelector`.
|
|
1967
|
+
* @private
|
|
1888
1968
|
* @return {?}
|
|
1889
1969
|
*/
|
|
1890
|
-
function (
|
|
1891
|
-
if (!this._dragging) {
|
|
1892
|
-
return this._draggables.toArray().indexOf(item);
|
|
1893
|
-
}
|
|
1894
|
-
// Items are sorted always by top/left in the cache, however they flow differently in RTL.
|
|
1895
|
-
// The rest of the logic still stands no matter what orientation we're in, however
|
|
1896
|
-
// we need to invert the array when determining the index.
|
|
1970
|
+
function () {
|
|
1897
1971
|
/** @type {?} */
|
|
1898
|
-
var
|
|
1899
|
-
|
|
1900
|
-
return findIndex(items, function (currentItem) { return currentItem.drag === item; });
|
|
1972
|
+
var selector = this.boundaryElementSelector;
|
|
1973
|
+
return selector ? getClosestMatchingAncestor(this.element.nativeElement, selector) : null;
|
|
1901
1974
|
};
|
|
1902
1975
|
/**
|
|
1903
|
-
*
|
|
1904
|
-
*
|
|
1905
|
-
* @param pointerX Position of the item along the X axis.
|
|
1906
|
-
* @param pointerY Position of the item along the Y axis.
|
|
1907
|
-
* @param pointerDeta Direction in which the pointer is moving along each axis.
|
|
1976
|
+
* Proxies the events from a DragRef to events that
|
|
1977
|
+
* match the interfaces of the CdkDrag outputs.
|
|
1908
1978
|
*/
|
|
1909
1979
|
/**
|
|
1910
|
-
*
|
|
1911
|
-
*
|
|
1912
|
-
* @
|
|
1913
|
-
* @param {?}
|
|
1914
|
-
* @param {?} pointerDelta
|
|
1980
|
+
* Proxies the events from a DragRef to events that
|
|
1981
|
+
* match the interfaces of the CdkDrag outputs.
|
|
1982
|
+
* @private
|
|
1983
|
+
* @param {?} ref
|
|
1915
1984
|
* @return {?}
|
|
1916
1985
|
*/
|
|
1917
|
-
|
|
1918
|
-
*
|
|
1919
|
-
*
|
|
1920
|
-
* @
|
|
1921
|
-
* @param {?}
|
|
1922
|
-
* @param {?} pointerDelta
|
|
1986
|
+
CdkDrag.prototype._proxyEvents = /**
|
|
1987
|
+
* Proxies the events from a DragRef to events that
|
|
1988
|
+
* match the interfaces of the CdkDrag outputs.
|
|
1989
|
+
* @private
|
|
1990
|
+
* @param {?} ref
|
|
1923
1991
|
* @return {?}
|
|
1924
1992
|
*/
|
|
1925
|
-
function (
|
|
1993
|
+
function (ref) {
|
|
1926
1994
|
var _this = this;
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
return;
|
|
1930
|
-
}
|
|
1931
|
-
/** @type {?} */
|
|
1932
|
-
var siblings = this._positionCache.items;
|
|
1933
|
-
/** @type {?} */
|
|
1934
|
-
var newIndex = this._getItemIndexFromPointerPosition(item, pointerX, pointerY, pointerDelta);
|
|
1935
|
-
if (newIndex === -1 && siblings.length > 0) {
|
|
1936
|
-
return;
|
|
1937
|
-
}
|
|
1938
|
-
/** @type {?} */
|
|
1939
|
-
var isHorizontal = this.orientation === 'horizontal';
|
|
1940
|
-
/** @type {?} */
|
|
1941
|
-
var currentIndex = findIndex(siblings, function (currentItem) { return currentItem.drag === item; });
|
|
1942
|
-
/** @type {?} */
|
|
1943
|
-
var siblingAtNewPosition = siblings[newIndex];
|
|
1944
|
-
/** @type {?} */
|
|
1945
|
-
var currentPosition = siblings[currentIndex].clientRect;
|
|
1946
|
-
/** @type {?} */
|
|
1947
|
-
var newPosition = siblingAtNewPosition.clientRect;
|
|
1948
|
-
/** @type {?} */
|
|
1949
|
-
var delta = currentIndex > newIndex ? 1 : -1;
|
|
1950
|
-
this._previousSwap.drag = siblingAtNewPosition.drag;
|
|
1951
|
-
this._previousSwap.delta = isHorizontal ? pointerDelta.x : pointerDelta.y;
|
|
1952
|
-
// How many pixels the item's placeholder should be offset.
|
|
1953
|
-
/** @type {?} */
|
|
1954
|
-
var itemOffset = this._getItemOffsetPx(currentPosition, newPosition, delta);
|
|
1955
|
-
// How many pixels all the other items should be offset.
|
|
1956
|
-
/** @type {?} */
|
|
1957
|
-
var siblingOffset = this._getSiblingOffsetPx(currentIndex, siblings, delta);
|
|
1958
|
-
// Save the previous order of the items before moving the item to its new index.
|
|
1959
|
-
// We use this to check whether an item has been moved as a result of the sorting.
|
|
1960
|
-
/** @type {?} */
|
|
1961
|
-
var oldOrder = siblings.slice();
|
|
1962
|
-
// Shuffle the array in place.
|
|
1963
|
-
moveItemInArray(siblings, currentIndex, newIndex);
|
|
1964
|
-
this.sorted.emit({
|
|
1965
|
-
previousIndex: currentIndex,
|
|
1966
|
-
currentIndex: newIndex,
|
|
1967
|
-
container: this,
|
|
1968
|
-
item: item
|
|
1995
|
+
ref.started.subscribe(function () {
|
|
1996
|
+
_this.started.emit({ source: _this });
|
|
1969
1997
|
});
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
if (oldOrder[index] === sibling) {
|
|
1973
|
-
return;
|
|
1974
|
-
}
|
|
1975
|
-
/** @type {?} */
|
|
1976
|
-
var isDraggedItem = sibling.drag === item;
|
|
1977
|
-
/** @type {?} */
|
|
1978
|
-
var offset = isDraggedItem ? itemOffset : siblingOffset;
|
|
1979
|
-
/** @type {?} */
|
|
1980
|
-
var elementToOffset = isDraggedItem ? item.getPlaceholderElement() :
|
|
1981
|
-
sibling.drag.getRootElement();
|
|
1982
|
-
// Update the offset to reflect the new position.
|
|
1983
|
-
sibling.offset += offset;
|
|
1984
|
-
// Since we're moving the items with a `transform`, we need to adjust their cached
|
|
1985
|
-
// client rects to reflect their new position, as well as swap their positions in the cache.
|
|
1986
|
-
// Note that we shouldn't use `getBoundingClientRect` here to update the cache, because the
|
|
1987
|
-
// elements may be mid-animation which will give us a wrong result.
|
|
1988
|
-
if (isHorizontal) {
|
|
1989
|
-
// Round the transforms since some browsers will
|
|
1990
|
-
// blur the elements, for sub-pixel transforms.
|
|
1991
|
-
elementToOffset.style.transform = "translate3d(" + Math.round(sibling.offset) + "px, 0, 0)";
|
|
1992
|
-
_this._adjustClientRect(sibling.clientRect, 0, offset);
|
|
1993
|
-
}
|
|
1994
|
-
else {
|
|
1995
|
-
elementToOffset.style.transform = "translate3d(0, " + Math.round(sibling.offset) + "px, 0)";
|
|
1996
|
-
_this._adjustClientRect(sibling.clientRect, offset, 0);
|
|
1997
|
-
}
|
|
1998
|
+
ref.released.subscribe(function () {
|
|
1999
|
+
_this.released.emit({ source: _this });
|
|
1998
2000
|
});
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
+
ref.ended.subscribe(function () {
|
|
2002
|
+
_this.ended.emit({ source: _this });
|
|
2003
|
+
});
|
|
2004
|
+
ref.entered.subscribe(function (event) {
|
|
2005
|
+
_this.entered.emit({
|
|
2006
|
+
container: event.container.data,
|
|
2007
|
+
item: _this
|
|
2008
|
+
});
|
|
2009
|
+
});
|
|
2010
|
+
ref.exited.subscribe(function (event) {
|
|
2011
|
+
_this.exited.emit({
|
|
2012
|
+
container: event.container.data,
|
|
2013
|
+
item: _this
|
|
2014
|
+
});
|
|
2015
|
+
});
|
|
2016
|
+
ref.dropped.subscribe(function (event) {
|
|
2017
|
+
_this.dropped.emit({
|
|
2018
|
+
previousIndex: event.previousIndex,
|
|
2019
|
+
currentIndex: event.currentIndex,
|
|
2020
|
+
previousContainer: event.previousContainer.data,
|
|
2021
|
+
container: event.container.data,
|
|
2022
|
+
isPointerOverContainer: event.isPointerOverContainer,
|
|
2023
|
+
item: _this
|
|
2024
|
+
});
|
|
2025
|
+
});
|
|
2026
|
+
};
|
|
2027
|
+
CdkDrag.decorators = [
|
|
2028
|
+
{ type: Directive, args: [{
|
|
2029
|
+
selector: '[cdkDrag]',
|
|
2030
|
+
exportAs: 'cdkDrag',
|
|
2031
|
+
host: {
|
|
2032
|
+
'class': 'cdk-drag',
|
|
2033
|
+
'[class.cdk-drag-dragging]': '_dragRef.isDragging()',
|
|
2034
|
+
},
|
|
2035
|
+
providers: [{ provide: CDK_DRAG_PARENT, useExisting: CdkDrag }]
|
|
2036
|
+
},] },
|
|
2037
|
+
];
|
|
2038
|
+
/** @nocollapse */
|
|
2039
|
+
CdkDrag.ctorParameters = function () { return [
|
|
2040
|
+
{ type: ElementRef },
|
|
2041
|
+
{ type: undefined, decorators: [{ type: Inject, args: [CDK_DROP_LIST,] }, { type: Optional }, { type: SkipSelf }] },
|
|
2042
|
+
{ type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] },
|
|
2043
|
+
{ type: NgZone },
|
|
2044
|
+
{ type: ViewContainerRef },
|
|
2045
|
+
{ type: ViewportRuler },
|
|
2046
|
+
{ type: DragDropRegistry },
|
|
2047
|
+
{ type: undefined, decorators: [{ type: Inject, args: [CDK_DRAG_CONFIG,] }] },
|
|
2048
|
+
{ type: Directionality, decorators: [{ type: Optional }] }
|
|
2049
|
+
]; };
|
|
2050
|
+
CdkDrag.propDecorators = {
|
|
2051
|
+
_handles: [{ type: ContentChildren, args: [CdkDragHandle, { descendants: true },] }],
|
|
2052
|
+
_previewTemplate: [{ type: ContentChild, args: [CdkDragPreview,] }],
|
|
2053
|
+
_placeholderTemplate: [{ type: ContentChild, args: [CdkDragPlaceholder,] }],
|
|
2054
|
+
data: [{ type: Input, args: ['cdkDragData',] }],
|
|
2055
|
+
lockAxis: [{ type: Input, args: ['cdkDragLockAxis',] }],
|
|
2056
|
+
rootElementSelector: [{ type: Input, args: ['cdkDragRootElement',] }],
|
|
2057
|
+
boundaryElementSelector: [{ type: Input, args: ['cdkDragBoundary',] }],
|
|
2058
|
+
disabled: [{ type: Input, args: ['cdkDragDisabled',] }],
|
|
2059
|
+
started: [{ type: Output, args: ['cdkDragStarted',] }],
|
|
2060
|
+
released: [{ type: Output, args: ['cdkDragReleased',] }],
|
|
2061
|
+
ended: [{ type: Output, args: ['cdkDragEnded',] }],
|
|
2062
|
+
entered: [{ type: Output, args: ['cdkDragEntered',] }],
|
|
2063
|
+
exited: [{ type: Output, args: ['cdkDragExited',] }],
|
|
2064
|
+
dropped: [{ type: Output, args: ['cdkDragDropped',] }],
|
|
2065
|
+
moved: [{ type: Output, args: ['cdkDragMoved',] }]
|
|
2066
|
+
};
|
|
2067
|
+
return CdkDrag;
|
|
2068
|
+
}());
|
|
2069
|
+
/**
|
|
2070
|
+
* Gets the closest ancestor of an element that matches a selector.
|
|
2071
|
+
* @param {?} element
|
|
2072
|
+
* @param {?} selector
|
|
2073
|
+
* @return {?}
|
|
2074
|
+
*/
|
|
2075
|
+
function getClosestMatchingAncestor(element, selector) {
|
|
2076
|
+
/** @type {?} */
|
|
2077
|
+
var currentElement = (/** @type {?} */ (element.parentElement));
|
|
2078
|
+
while (currentElement) {
|
|
2079
|
+
// IE doesn't support `matches` so we have to fall back to `msMatchesSelector`.
|
|
2080
|
+
if (currentElement.matches ? currentElement.matches(selector) :
|
|
2081
|
+
((/** @type {?} */ (currentElement))).msMatchesSelector(selector)) {
|
|
2082
|
+
return currentElement;
|
|
2083
|
+
}
|
|
2084
|
+
currentElement = currentElement.parentElement;
|
|
2085
|
+
}
|
|
2086
|
+
return null;
|
|
2087
|
+
}
|
|
2088
|
+
|
|
2089
|
+
/**
|
|
2090
|
+
* @fileoverview added by tsickle
|
|
2091
|
+
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2092
|
+
*/
|
|
2093
|
+
/**
|
|
2094
|
+
* Declaratively connects sibling `cdkDropList` instances together. All of the `cdkDropList`
|
|
2095
|
+
* elements that are placed inside a `cdkDropListGroup` will be connected to each other
|
|
2096
|
+
* automatically. Can be used as an alternative to the `cdkDropListConnectedTo` input
|
|
2097
|
+
* from `cdkDropList`.
|
|
2098
|
+
* @template T
|
|
2099
|
+
*/
|
|
2100
|
+
var CdkDropListGroup = /** @class */ (function () {
|
|
2101
|
+
function CdkDropListGroup() {
|
|
2102
|
+
/**
|
|
2103
|
+
* Drop lists registered inside the group.
|
|
2104
|
+
*/
|
|
2105
|
+
this._items = new Set();
|
|
2106
|
+
this._disabled = false;
|
|
2107
|
+
}
|
|
2108
|
+
Object.defineProperty(CdkDropListGroup.prototype, "disabled", {
|
|
2109
|
+
/** Whether starting a dragging sequence from inside this group is disabled. */
|
|
2110
|
+
get: /**
|
|
2111
|
+
* Whether starting a dragging sequence from inside this group is disabled.
|
|
2112
|
+
* @return {?}
|
|
2113
|
+
*/
|
|
2114
|
+
function () { return this._disabled; },
|
|
2115
|
+
set: /**
|
|
2116
|
+
* @param {?} value
|
|
2117
|
+
* @return {?}
|
|
2118
|
+
*/
|
|
2119
|
+
function (value) {
|
|
2120
|
+
this._disabled = coerceBooleanProperty(value);
|
|
2121
|
+
},
|
|
2122
|
+
enumerable: true,
|
|
2123
|
+
configurable: true
|
|
2124
|
+
});
|
|
2125
|
+
/**
|
|
2126
|
+
* @return {?}
|
|
2127
|
+
*/
|
|
2128
|
+
CdkDropListGroup.prototype.ngOnDestroy = /**
|
|
2129
|
+
* @return {?}
|
|
2130
|
+
*/
|
|
2131
|
+
function () {
|
|
2132
|
+
this._items.clear();
|
|
2133
|
+
};
|
|
2134
|
+
CdkDropListGroup.decorators = [
|
|
2135
|
+
{ type: Directive, args: [{
|
|
2136
|
+
selector: '[cdkDropListGroup]',
|
|
2137
|
+
exportAs: 'cdkDropListGroup',
|
|
2138
|
+
},] },
|
|
2139
|
+
];
|
|
2140
|
+
CdkDropListGroup.propDecorators = {
|
|
2141
|
+
disabled: [{ type: Input, args: ['cdkDropListGroupDisabled',] }]
|
|
2142
|
+
};
|
|
2143
|
+
return CdkDropListGroup;
|
|
2144
|
+
}());
|
|
2145
|
+
|
|
2146
|
+
/**
|
|
2147
|
+
* @fileoverview added by tsickle
|
|
2148
|
+
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2149
|
+
*/
|
|
2150
|
+
/**
|
|
2151
|
+
* Counter used to generate unique ids for drop refs.
|
|
2152
|
+
* @type {?}
|
|
2153
|
+
*/
|
|
2154
|
+
var _uniqueIdCounter = 0;
|
|
2155
|
+
/**
|
|
2156
|
+
* Proximity, as a ratio to width/height, at which a
|
|
2157
|
+
* dragged item will affect the drop container.
|
|
2158
|
+
* @type {?}
|
|
2159
|
+
*/
|
|
2160
|
+
var DROP_PROXIMITY_THRESHOLD = 0.05;
|
|
2161
|
+
/**
|
|
2162
|
+
* Reference to a drop list. Used to manipulate or dispose of the container.
|
|
2163
|
+
* \@docs-private
|
|
2164
|
+
* @template T
|
|
2165
|
+
*/
|
|
2166
|
+
var /**
|
|
2167
|
+
* Reference to a drop list. Used to manipulate or dispose of the container.
|
|
2168
|
+
* \@docs-private
|
|
2169
|
+
* @template T
|
|
2170
|
+
*/
|
|
2171
|
+
DropListRef = /** @class */ (function () {
|
|
2172
|
+
function DropListRef(element, _dragDropRegistry, _document, _dir) {
|
|
2173
|
+
this.element = element;
|
|
2174
|
+
this._dragDropRegistry = _dragDropRegistry;
|
|
2175
|
+
this._dir = _dir;
|
|
2176
|
+
/**
|
|
2177
|
+
* Unique ID for the drop list.
|
|
2178
|
+
* @deprecated No longer being used. To be removed.
|
|
2179
|
+
* \@breaking-change 8.0.0
|
|
2180
|
+
*/
|
|
2181
|
+
this.id = "cdk-drop-list-ref-" + _uniqueIdCounter++;
|
|
2182
|
+
/**
|
|
2183
|
+
* Whether starting a dragging sequence from this container is disabled.
|
|
2184
|
+
*/
|
|
2185
|
+
this.disabled = false;
|
|
2186
|
+
/**
|
|
2187
|
+
* Function that is used to determine whether an item
|
|
2188
|
+
* is allowed to be moved into a drop container.
|
|
2189
|
+
*/
|
|
2190
|
+
this.enterPredicate = function () { return true; };
|
|
2191
|
+
/**
|
|
2192
|
+
* Emits right before dragging has started.
|
|
2193
|
+
*/
|
|
2194
|
+
this.beforeStarted = new Subject();
|
|
2195
|
+
/**
|
|
2196
|
+
* Emits when the user has moved a new drag item into this container.
|
|
2197
|
+
*/
|
|
2198
|
+
this.entered = new Subject();
|
|
2199
|
+
/**
|
|
2200
|
+
* Emits when the user removes an item from the container
|
|
2201
|
+
* by dragging it into another container.
|
|
2202
|
+
*/
|
|
2203
|
+
this.exited = new Subject();
|
|
2204
|
+
/**
|
|
2205
|
+
* Emits when the user drops an item inside the container.
|
|
2206
|
+
*/
|
|
2207
|
+
this.dropped = new Subject();
|
|
2208
|
+
/**
|
|
2209
|
+
* Emits as the user is swapping items while actively dragging.
|
|
2210
|
+
*/
|
|
2211
|
+
this.sorted = new Subject();
|
|
2212
|
+
/**
|
|
2213
|
+
* Whether an item in the list is being dragged.
|
|
2214
|
+
*/
|
|
2215
|
+
this._isDragging = false;
|
|
2216
|
+
/**
|
|
2217
|
+
* Cache of the dimensions of all the items and the sibling containers.
|
|
2218
|
+
*/
|
|
2219
|
+
this._positionCache = { items: [], siblings: [], self: (/** @type {?} */ ({})) };
|
|
2220
|
+
/**
|
|
2221
|
+
* Keeps track of the item that was last swapped with the dragged item, as
|
|
2222
|
+
* well as what direction the pointer was moving in when the swap occured.
|
|
2223
|
+
*/
|
|
2224
|
+
this._previousSwap = { drag: (/** @type {?} */ (null)), delta: 0 };
|
|
2225
|
+
this._siblings = [];
|
|
2226
|
+
/**
|
|
2227
|
+
* Direction in which the list is oriented.
|
|
2228
|
+
*/
|
|
2229
|
+
this._orientation = 'vertical';
|
|
2230
|
+
/**
|
|
2231
|
+
* Amount of connected siblings that currently have a dragged item.
|
|
2232
|
+
*/
|
|
2233
|
+
this._activeSiblings = 0;
|
|
2234
|
+
_dragDropRegistry.registerDropContainer(this);
|
|
2235
|
+
this._document = _document;
|
|
2236
|
+
}
|
|
2237
|
+
/** Removes the drop list functionality from the DOM element. */
|
|
2238
|
+
/**
|
|
2239
|
+
* Removes the drop list functionality from the DOM element.
|
|
2240
|
+
* @return {?}
|
|
2241
|
+
*/
|
|
2242
|
+
DropListRef.prototype.dispose = /**
|
|
2243
|
+
* Removes the drop list functionality from the DOM element.
|
|
2244
|
+
* @return {?}
|
|
2245
|
+
*/
|
|
2246
|
+
function () {
|
|
2247
|
+
this.beforeStarted.complete();
|
|
2248
|
+
this.entered.complete();
|
|
2249
|
+
this.exited.complete();
|
|
2250
|
+
this.dropped.complete();
|
|
2251
|
+
this.sorted.complete();
|
|
2252
|
+
this._dragDropRegistry.removeDropContainer(this);
|
|
2253
|
+
};
|
|
2254
|
+
/** Whether an item from this list is currently being dragged. */
|
|
2255
|
+
/**
|
|
2256
|
+
* Whether an item from this list is currently being dragged.
|
|
2257
|
+
* @return {?}
|
|
2258
|
+
*/
|
|
2259
|
+
DropListRef.prototype.isDragging = /**
|
|
2260
|
+
* Whether an item from this list is currently being dragged.
|
|
2261
|
+
* @return {?}
|
|
2262
|
+
*/
|
|
2263
|
+
function () {
|
|
2264
|
+
return this._isDragging;
|
|
2265
|
+
};
|
|
2266
|
+
/** Starts dragging an item. */
|
|
2267
|
+
/**
|
|
2268
|
+
* Starts dragging an item.
|
|
2269
|
+
* @return {?}
|
|
2270
|
+
*/
|
|
2271
|
+
DropListRef.prototype.start = /**
|
|
2272
|
+
* Starts dragging an item.
|
|
2273
|
+
* @return {?}
|
|
2274
|
+
*/
|
|
2275
|
+
function () {
|
|
2276
|
+
this.beforeStarted.next();
|
|
2277
|
+
this._isDragging = true;
|
|
2278
|
+
this._activeDraggables = this._draggables.slice();
|
|
2279
|
+
this._cachePositions();
|
|
2280
|
+
this._positionCache.siblings.forEach(function (sibling) { return sibling.drop._toggleIsReceiving(true); });
|
|
2281
|
+
};
|
|
2282
|
+
/**
|
|
2283
|
+
* Emits an event to indicate that the user moved an item into the container.
|
|
2284
|
+
* @param item Item that was moved into the container.
|
|
2285
|
+
* @param pointerX Position of the item along the X axis.
|
|
2286
|
+
* @param pointerY Position of the item along the Y axis.
|
|
2287
|
+
*/
|
|
2288
|
+
/**
|
|
2289
|
+
* Emits an event to indicate that the user moved an item into the container.
|
|
2290
|
+
* @param {?} item Item that was moved into the container.
|
|
2291
|
+
* @param {?} pointerX Position of the item along the X axis.
|
|
2292
|
+
* @param {?} pointerY Position of the item along the Y axis.
|
|
2293
|
+
* @return {?}
|
|
2294
|
+
*/
|
|
2295
|
+
DropListRef.prototype.enter = /**
|
|
2296
|
+
* Emits an event to indicate that the user moved an item into the container.
|
|
2297
|
+
* @param {?} item Item that was moved into the container.
|
|
2298
|
+
* @param {?} pointerX Position of the item along the X axis.
|
|
2299
|
+
* @param {?} pointerY Position of the item along the Y axis.
|
|
2300
|
+
* @return {?}
|
|
2301
|
+
*/
|
|
2302
|
+
function (item, pointerX, pointerY) {
|
|
2303
|
+
this.entered.next({ item: item, container: this });
|
|
2304
|
+
this.start();
|
|
2305
|
+
// We use the coordinates of where the item entered the drop
|
|
2306
|
+
// zone to figure out at which index it should be inserted.
|
|
2307
|
+
/** @type {?} */
|
|
2308
|
+
var newIndex = this._getItemIndexFromPointerPosition(item, pointerX, pointerY);
|
|
2309
|
+
/** @type {?} */
|
|
2310
|
+
var currentIndex = this._activeDraggables.indexOf(item);
|
|
2311
|
+
/** @type {?} */
|
|
2312
|
+
var newPositionReference = this._activeDraggables[newIndex];
|
|
2313
|
+
/** @type {?} */
|
|
2314
|
+
var placeholder = item.getPlaceholderElement();
|
|
2315
|
+
// Since the item may be in the `activeDraggables` already (e.g. if the user dragged it
|
|
2316
|
+
// into another container and back again), we have to ensure that it isn't duplicated.
|
|
2317
|
+
if (currentIndex > -1) {
|
|
2318
|
+
this._activeDraggables.splice(currentIndex, 1);
|
|
2319
|
+
}
|
|
2320
|
+
// Don't use items that are being dragged as a reference, because
|
|
2321
|
+
// their element has been moved down to the bottom of the body.
|
|
2322
|
+
if (newPositionReference && !this._dragDropRegistry.isDragging(newPositionReference)) {
|
|
2323
|
+
/** @type {?} */
|
|
2324
|
+
var element = newPositionReference.getRootElement();
|
|
2325
|
+
(/** @type {?} */ (element.parentElement)).insertBefore(placeholder, element);
|
|
2326
|
+
this._activeDraggables.splice(newIndex, 0, item);
|
|
2327
|
+
}
|
|
2328
|
+
else {
|
|
2329
|
+
this.element.nativeElement.appendChild(placeholder);
|
|
2330
|
+
this._activeDraggables.push(item);
|
|
2331
|
+
}
|
|
2332
|
+
// The transform needs to be cleared so it doesn't throw off the measurements.
|
|
2333
|
+
placeholder.style.transform = '';
|
|
2334
|
+
// Note that the positions were already cached when we called `start` above,
|
|
2335
|
+
// but we need to refresh them since the amount of items has changed.
|
|
2336
|
+
this._cachePositions();
|
|
2337
|
+
};
|
|
2338
|
+
/**
|
|
2339
|
+
* Removes an item from the container after it was dragged into another container by the user.
|
|
2340
|
+
* @param item Item that was dragged out.
|
|
2341
|
+
*/
|
|
2342
|
+
/**
|
|
2343
|
+
* Removes an item from the container after it was dragged into another container by the user.
|
|
2344
|
+
* @param {?} item Item that was dragged out.
|
|
2345
|
+
* @return {?}
|
|
2346
|
+
*/
|
|
2347
|
+
DropListRef.prototype.exit = /**
|
|
2348
|
+
* Removes an item from the container after it was dragged into another container by the user.
|
|
2349
|
+
* @param {?} item Item that was dragged out.
|
|
2350
|
+
* @return {?}
|
|
2351
|
+
*/
|
|
2352
|
+
function (item) {
|
|
2353
|
+
this._reset();
|
|
2354
|
+
this.exited.next({ item: item, container: this });
|
|
2355
|
+
};
|
|
2356
|
+
/**
|
|
2357
|
+
* Drops an item into this container.
|
|
2358
|
+
* @param item Item being dropped into the container.
|
|
2359
|
+
* @param currentIndex Index at which the item should be inserted.
|
|
2360
|
+
* @param previousContainer Container from which the item got dragged in.
|
|
2361
|
+
* @param isPointerOverContainer Whether the user's pointer was over the
|
|
2362
|
+
* container when the item was dropped.
|
|
2363
|
+
*/
|
|
2364
|
+
/**
|
|
2365
|
+
* Drops an item into this container.
|
|
2366
|
+
* @param {?} item Item being dropped into the container.
|
|
2367
|
+
* @param {?} currentIndex Index at which the item should be inserted.
|
|
2368
|
+
* @param {?} previousContainer Container from which the item got dragged in.
|
|
2369
|
+
* @param {?} isPointerOverContainer Whether the user's pointer was over the
|
|
2370
|
+
* container when the item was dropped.
|
|
2371
|
+
* @return {?}
|
|
2372
|
+
*/
|
|
2373
|
+
DropListRef.prototype.drop = /**
|
|
2374
|
+
* Drops an item into this container.
|
|
2375
|
+
* @param {?} item Item being dropped into the container.
|
|
2376
|
+
* @param {?} currentIndex Index at which the item should be inserted.
|
|
2377
|
+
* @param {?} previousContainer Container from which the item got dragged in.
|
|
2378
|
+
* @param {?} isPointerOverContainer Whether the user's pointer was over the
|
|
2379
|
+
* container when the item was dropped.
|
|
2380
|
+
* @return {?}
|
|
2381
|
+
*/
|
|
2382
|
+
function (item, currentIndex, previousContainer, isPointerOverContainer) {
|
|
2383
|
+
this._reset();
|
|
2384
|
+
this.dropped.next({
|
|
2385
|
+
item: item,
|
|
2386
|
+
currentIndex: currentIndex,
|
|
2387
|
+
previousIndex: previousContainer.getItemIndex(item),
|
|
2388
|
+
container: this,
|
|
2389
|
+
previousContainer: previousContainer,
|
|
2390
|
+
isPointerOverContainer: isPointerOverContainer
|
|
2391
|
+
});
|
|
2392
|
+
};
|
|
2393
|
+
/**
|
|
2394
|
+
* Sets the draggable items that are a part of this list.
|
|
2395
|
+
* @param items Items that are a part of this list.
|
|
2396
|
+
*/
|
|
2397
|
+
/**
|
|
2398
|
+
* Sets the draggable items that are a part of this list.
|
|
2399
|
+
* @template THIS
|
|
2400
|
+
* @this {THIS}
|
|
2401
|
+
* @param {?} items Items that are a part of this list.
|
|
2402
|
+
* @return {THIS}
|
|
2403
|
+
*/
|
|
2404
|
+
DropListRef.prototype.withItems = /**
|
|
2405
|
+
* Sets the draggable items that are a part of this list.
|
|
2406
|
+
* @template THIS
|
|
2407
|
+
* @this {THIS}
|
|
2408
|
+
* @param {?} items Items that are a part of this list.
|
|
2409
|
+
* @return {THIS}
|
|
2410
|
+
*/
|
|
2411
|
+
function (items) {
|
|
2412
|
+
(/** @type {?} */ (this))._draggables = items.slice();
|
|
2413
|
+
return (/** @type {?} */ (this));
|
|
2414
|
+
};
|
|
2415
|
+
/**
|
|
2416
|
+
* Sets the containers that are connected to this one. When two or more containers are
|
|
2417
|
+
* connected, the user will be allowed to transfer items between them.
|
|
2418
|
+
* @param connectedTo Other containers that the current containers should be connected to.
|
|
2419
|
+
*/
|
|
2420
|
+
/**
|
|
2421
|
+
* Sets the containers that are connected to this one. When two or more containers are
|
|
2422
|
+
* connected, the user will be allowed to transfer items between them.
|
|
2423
|
+
* @template THIS
|
|
2424
|
+
* @this {THIS}
|
|
2425
|
+
* @param {?} connectedTo Other containers that the current containers should be connected to.
|
|
2426
|
+
* @return {THIS}
|
|
2427
|
+
*/
|
|
2428
|
+
DropListRef.prototype.connectedTo = /**
|
|
2429
|
+
* Sets the containers that are connected to this one. When two or more containers are
|
|
2430
|
+
* connected, the user will be allowed to transfer items between them.
|
|
2431
|
+
* @template THIS
|
|
2432
|
+
* @this {THIS}
|
|
2433
|
+
* @param {?} connectedTo Other containers that the current containers should be connected to.
|
|
2434
|
+
* @return {THIS}
|
|
2435
|
+
*/
|
|
2436
|
+
function (connectedTo) {
|
|
2437
|
+
(/** @type {?} */ (this))._siblings = connectedTo.slice();
|
|
2438
|
+
return (/** @type {?} */ (this));
|
|
2439
|
+
};
|
|
2440
|
+
/**
|
|
2441
|
+
* Sets the orientation of the container.
|
|
2442
|
+
* @param orientation New orientation for the container.
|
|
2443
|
+
*/
|
|
2444
|
+
/**
|
|
2445
|
+
* Sets the orientation of the container.
|
|
2446
|
+
* @template THIS
|
|
2447
|
+
* @this {THIS}
|
|
2448
|
+
* @param {?} orientation New orientation for the container.
|
|
2449
|
+
* @return {THIS}
|
|
2450
|
+
*/
|
|
2451
|
+
DropListRef.prototype.withOrientation = /**
|
|
2452
|
+
* Sets the orientation of the container.
|
|
2453
|
+
* @template THIS
|
|
2454
|
+
* @this {THIS}
|
|
2455
|
+
* @param {?} orientation New orientation for the container.
|
|
2456
|
+
* @return {THIS}
|
|
2457
|
+
*/
|
|
2458
|
+
function (orientation) {
|
|
2459
|
+
(/** @type {?} */ (this))._orientation = orientation;
|
|
2460
|
+
return (/** @type {?} */ (this));
|
|
2461
|
+
};
|
|
2462
|
+
/**
|
|
2463
|
+
* Figures out the index of an item in the container.
|
|
2464
|
+
* @param item Item whose index should be determined.
|
|
2465
|
+
*/
|
|
2466
|
+
/**
|
|
2467
|
+
* Figures out the index of an item in the container.
|
|
2468
|
+
* @param {?} item Item whose index should be determined.
|
|
2469
|
+
* @return {?}
|
|
2470
|
+
*/
|
|
2471
|
+
DropListRef.prototype.getItemIndex = /**
|
|
2472
|
+
* Figures out the index of an item in the container.
|
|
2473
|
+
* @param {?} item Item whose index should be determined.
|
|
2474
|
+
* @return {?}
|
|
2475
|
+
*/
|
|
2476
|
+
function (item) {
|
|
2477
|
+
if (!this._isDragging) {
|
|
2478
|
+
return this._draggables.indexOf(item);
|
|
2479
|
+
}
|
|
2480
|
+
// Items are sorted always by top/left in the cache, however they flow differently in RTL.
|
|
2481
|
+
// The rest of the logic still stands no matter what orientation we're in, however
|
|
2482
|
+
// we need to invert the array when determining the index.
|
|
2483
|
+
/** @type {?} */
|
|
2484
|
+
var items = this._orientation === 'horizontal' && this._dir && this._dir.value === 'rtl' ?
|
|
2485
|
+
this._positionCache.items.slice().reverse() : this._positionCache.items;
|
|
2486
|
+
return findIndex(items, function (currentItem) { return currentItem.drag === item; });
|
|
2487
|
+
};
|
|
2488
|
+
/**
|
|
2489
|
+
* Whether the list is able to receive the item that
|
|
2490
|
+
* is currently being dragged inside a connected drop list.
|
|
2491
|
+
*/
|
|
2492
|
+
/**
|
|
2493
|
+
* Whether the list is able to receive the item that
|
|
2494
|
+
* is currently being dragged inside a connected drop list.
|
|
2495
|
+
* @return {?}
|
|
2496
|
+
*/
|
|
2497
|
+
DropListRef.prototype.isReceiving = /**
|
|
2498
|
+
* Whether the list is able to receive the item that
|
|
2499
|
+
* is currently being dragged inside a connected drop list.
|
|
2500
|
+
* @return {?}
|
|
2501
|
+
*/
|
|
2502
|
+
function () {
|
|
2503
|
+
return this._activeSiblings > 0;
|
|
2504
|
+
};
|
|
2505
|
+
/**
|
|
2506
|
+
* Sorts an item inside the container based on its position.
|
|
2507
|
+
* @param item Item to be sorted.
|
|
2508
|
+
* @param pointerX Position of the item along the X axis.
|
|
2509
|
+
* @param pointerY Position of the item along the Y axis.
|
|
2510
|
+
* @param pointerDelta Direction in which the pointer is moving along each axis.
|
|
2511
|
+
*/
|
|
2512
|
+
/**
|
|
2513
|
+
* Sorts an item inside the container based on its position.
|
|
2514
|
+
* @param {?} item Item to be sorted.
|
|
2515
|
+
* @param {?} pointerX Position of the item along the X axis.
|
|
2516
|
+
* @param {?} pointerY Position of the item along the Y axis.
|
|
2517
|
+
* @param {?} pointerDelta Direction in which the pointer is moving along each axis.
|
|
2518
|
+
* @return {?}
|
|
2519
|
+
*/
|
|
2520
|
+
DropListRef.prototype._sortItem = /**
|
|
2521
|
+
* Sorts an item inside the container based on its position.
|
|
2522
|
+
* @param {?} item Item to be sorted.
|
|
2523
|
+
* @param {?} pointerX Position of the item along the X axis.
|
|
2524
|
+
* @param {?} pointerY Position of the item along the Y axis.
|
|
2525
|
+
* @param {?} pointerDelta Direction in which the pointer is moving along each axis.
|
|
2526
|
+
* @return {?}
|
|
2527
|
+
*/
|
|
2528
|
+
function (item, pointerX, pointerY, pointerDelta) {
|
|
2529
|
+
// Don't sort the item if it's out of range.
|
|
2530
|
+
if (!this._isPointerNearDropContainer(pointerX, pointerY)) {
|
|
2531
|
+
return;
|
|
2532
|
+
}
|
|
2533
|
+
/** @type {?} */
|
|
2534
|
+
var siblings = this._positionCache.items;
|
|
2535
|
+
/** @type {?} */
|
|
2536
|
+
var newIndex = this._getItemIndexFromPointerPosition(item, pointerX, pointerY, pointerDelta);
|
|
2537
|
+
if (newIndex === -1 && siblings.length > 0) {
|
|
2538
|
+
return;
|
|
2539
|
+
}
|
|
2540
|
+
/** @type {?} */
|
|
2541
|
+
var isHorizontal = this._orientation === 'horizontal';
|
|
2542
|
+
/** @type {?} */
|
|
2543
|
+
var currentIndex = findIndex(siblings, function (currentItem) { return currentItem.drag === item; });
|
|
2544
|
+
/** @type {?} */
|
|
2545
|
+
var siblingAtNewPosition = siblings[newIndex];
|
|
2546
|
+
/** @type {?} */
|
|
2547
|
+
var currentPosition = siblings[currentIndex].clientRect;
|
|
2548
|
+
/** @type {?} */
|
|
2549
|
+
var newPosition = siblingAtNewPosition.clientRect;
|
|
2550
|
+
/** @type {?} */
|
|
2551
|
+
var delta = currentIndex > newIndex ? 1 : -1;
|
|
2552
|
+
this._previousSwap.drag = siblingAtNewPosition.drag;
|
|
2553
|
+
this._previousSwap.delta = isHorizontal ? pointerDelta.x : pointerDelta.y;
|
|
2554
|
+
// How many pixels the item's placeholder should be offset.
|
|
2555
|
+
/** @type {?} */
|
|
2556
|
+
var itemOffset = this._getItemOffsetPx(currentPosition, newPosition, delta);
|
|
2557
|
+
// How many pixels all the other items should be offset.
|
|
2558
|
+
/** @type {?} */
|
|
2559
|
+
var siblingOffset = this._getSiblingOffsetPx(currentIndex, siblings, delta);
|
|
2560
|
+
// Save the previous order of the items before moving the item to its new index.
|
|
2561
|
+
// We use this to check whether an item has been moved as a result of the sorting.
|
|
2562
|
+
/** @type {?} */
|
|
2563
|
+
var oldOrder = siblings.slice();
|
|
2564
|
+
// Shuffle the array in place.
|
|
2565
|
+
moveItemInArray(siblings, currentIndex, newIndex);
|
|
2566
|
+
this.sorted.next({
|
|
2567
|
+
previousIndex: currentIndex,
|
|
2568
|
+
currentIndex: newIndex,
|
|
2569
|
+
container: this,
|
|
2570
|
+
item: item
|
|
2571
|
+
});
|
|
2572
|
+
siblings.forEach(function (sibling, index) {
|
|
2573
|
+
// Don't do anything if the position hasn't changed.
|
|
2574
|
+
if (oldOrder[index] === sibling) {
|
|
2575
|
+
return;
|
|
2576
|
+
}
|
|
2577
|
+
/** @type {?} */
|
|
2578
|
+
var isDraggedItem = sibling.drag === item;
|
|
2579
|
+
/** @type {?} */
|
|
2580
|
+
var offset = isDraggedItem ? itemOffset : siblingOffset;
|
|
2581
|
+
/** @type {?} */
|
|
2582
|
+
var elementToOffset = isDraggedItem ? item.getPlaceholderElement() :
|
|
2583
|
+
sibling.drag.getRootElement();
|
|
2584
|
+
// Update the offset to reflect the new position.
|
|
2585
|
+
sibling.offset += offset;
|
|
2586
|
+
// Since we're moving the items with a `transform`, we need to adjust their cached
|
|
2587
|
+
// client rects to reflect their new position, as well as swap their positions in the cache.
|
|
2588
|
+
// Note that we shouldn't use `getBoundingClientRect` here to update the cache, because the
|
|
2589
|
+
// elements may be mid-animation which will give us a wrong result.
|
|
2590
|
+
if (isHorizontal) {
|
|
2591
|
+
// Round the transforms since some browsers will
|
|
2592
|
+
// blur the elements, for sub-pixel transforms.
|
|
2593
|
+
elementToOffset.style.transform = "translate3d(" + Math.round(sibling.offset) + "px, 0, 0)";
|
|
2594
|
+
adjustClientRect(sibling.clientRect, 0, offset);
|
|
2595
|
+
}
|
|
2596
|
+
else {
|
|
2597
|
+
elementToOffset.style.transform = "translate3d(0, " + Math.round(sibling.offset) + "px, 0)";
|
|
2598
|
+
adjustClientRect(sibling.clientRect, offset, 0);
|
|
2599
|
+
}
|
|
2600
|
+
});
|
|
2601
|
+
};
|
|
2602
|
+
/** Refreshes the position cache of the items and sibling containers. */
|
|
2603
|
+
/**
|
|
2604
|
+
* Refreshes the position cache of the items and sibling containers.
|
|
2605
|
+
* @private
|
|
2606
|
+
* @return {?}
|
|
2607
|
+
*/
|
|
2608
|
+
DropListRef.prototype._cachePositions = /**
|
|
2609
|
+
* Refreshes the position cache of the items and sibling containers.
|
|
2610
|
+
* @private
|
|
2611
|
+
* @return {?}
|
|
2612
|
+
*/
|
|
2613
|
+
function () {
|
|
2614
|
+
var _this = this;
|
|
2615
|
+
/** @type {?} */
|
|
2616
|
+
var isHorizontal = this._orientation === 'horizontal';
|
|
2617
|
+
this._positionCache.self = this.element.nativeElement.getBoundingClientRect();
|
|
2618
|
+
this._positionCache.items = this._activeDraggables
|
|
2619
|
+
.map(function (drag) {
|
|
2620
|
+
/** @type {?} */
|
|
2621
|
+
var elementToMeasure = _this._dragDropRegistry.isDragging(drag) ?
|
|
2622
|
+
// If the element is being dragged, we have to measure the
|
|
2623
|
+
// placeholder, because the element is hidden.
|
|
2624
|
+
drag.getPlaceholderElement() :
|
|
2625
|
+
drag.getRootElement();
|
|
2626
|
+
/** @type {?} */
|
|
2627
|
+
var clientRect = elementToMeasure.getBoundingClientRect();
|
|
2628
|
+
return {
|
|
2629
|
+
drag: drag,
|
|
2630
|
+
offset: 0,
|
|
2631
|
+
// We need to clone the `clientRect` here, because all the values on it are readonly
|
|
2632
|
+
// and we need to be able to update them. Also we can't use a spread here, because
|
|
2633
|
+
// the values on a `ClientRect` aren't own properties. See:
|
|
2634
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect#Notes
|
|
2635
|
+
clientRect: {
|
|
2636
|
+
top: clientRect.top,
|
|
2637
|
+
right: clientRect.right,
|
|
2638
|
+
bottom: clientRect.bottom,
|
|
2639
|
+
left: clientRect.left,
|
|
2640
|
+
width: clientRect.width,
|
|
2641
|
+
height: clientRect.height
|
|
2642
|
+
}
|
|
2643
|
+
};
|
|
2644
|
+
})
|
|
2645
|
+
.sort(function (a, b) {
|
|
2646
|
+
return isHorizontal ? a.clientRect.left - b.clientRect.left :
|
|
2647
|
+
a.clientRect.top - b.clientRect.top;
|
|
2648
|
+
});
|
|
2649
|
+
this._positionCache.siblings = this._siblings.map(function (drop) { return ({
|
|
2650
|
+
drop: drop,
|
|
2651
|
+
clientRect: drop.element.nativeElement.getBoundingClientRect()
|
|
2652
|
+
}); });
|
|
2653
|
+
};
|
|
2654
|
+
/**
|
|
2655
|
+
* Toggles whether the list can receive the item that is currently being dragged.
|
|
2656
|
+
* Usually called by a sibling that initiated the dragging.
|
|
2657
|
+
*/
|
|
2658
|
+
/**
|
|
2659
|
+
* Toggles whether the list can receive the item that is currently being dragged.
|
|
2660
|
+
* Usually called by a sibling that initiated the dragging.
|
|
2661
|
+
* @param {?} isDragging
|
|
2662
|
+
* @return {?}
|
|
2663
|
+
*/
|
|
2664
|
+
DropListRef.prototype._toggleIsReceiving = /**
|
|
2665
|
+
* Toggles whether the list can receive the item that is currently being dragged.
|
|
2666
|
+
* Usually called by a sibling that initiated the dragging.
|
|
2667
|
+
* @param {?} isDragging
|
|
2668
|
+
* @return {?}
|
|
2669
|
+
*/
|
|
2670
|
+
function (isDragging) {
|
|
2671
|
+
this._activeSiblings = Math.max(0, this._activeSiblings + (isDragging ? 1 : -1));
|
|
2672
|
+
};
|
|
2673
|
+
/** Resets the container to its initial state. */
|
|
2674
|
+
/**
|
|
2675
|
+
* Resets the container to its initial state.
|
|
2676
|
+
* @private
|
|
2677
|
+
* @return {?}
|
|
2678
|
+
*/
|
|
2679
|
+
DropListRef.prototype._reset = /**
|
|
2680
|
+
* Resets the container to its initial state.
|
|
2681
|
+
* @private
|
|
2682
|
+
* @return {?}
|
|
2683
|
+
*/
|
|
2684
|
+
function () {
|
|
2685
|
+
this._isDragging = false;
|
|
2686
|
+
// TODO(crisbeto): may have to wait for the animations to finish.
|
|
2687
|
+
this._activeDraggables.forEach(function (item) { return item.getRootElement().style.transform = ''; });
|
|
2688
|
+
this._positionCache.siblings.forEach(function (sibling) { return sibling.drop._toggleIsReceiving(false); });
|
|
2689
|
+
this._activeDraggables = [];
|
|
2690
|
+
this._positionCache.items = [];
|
|
2691
|
+
this._positionCache.siblings = [];
|
|
2692
|
+
this._previousSwap.drag = null;
|
|
2693
|
+
this._previousSwap.delta = 0;
|
|
2694
|
+
};
|
|
2695
|
+
/**
|
|
2696
|
+
* Gets the offset in pixels by which the items that aren't being dragged should be moved.
|
|
2697
|
+
* @param currentIndex Index of the item currently being dragged.
|
|
2698
|
+
* @param siblings All of the items in the list.
|
|
2699
|
+
* @param delta Direction in which the user is moving.
|
|
2700
|
+
*/
|
|
2701
|
+
/**
|
|
2702
|
+
* Gets the offset in pixels by which the items that aren't being dragged should be moved.
|
|
2703
|
+
* @private
|
|
2704
|
+
* @param {?} currentIndex Index of the item currently being dragged.
|
|
2705
|
+
* @param {?} siblings All of the items in the list.
|
|
2706
|
+
* @param {?} delta Direction in which the user is moving.
|
|
2707
|
+
* @return {?}
|
|
2708
|
+
*/
|
|
2709
|
+
DropListRef.prototype._getSiblingOffsetPx = /**
|
|
2710
|
+
* Gets the offset in pixels by which the items that aren't being dragged should be moved.
|
|
2711
|
+
* @private
|
|
2712
|
+
* @param {?} currentIndex Index of the item currently being dragged.
|
|
2713
|
+
* @param {?} siblings All of the items in the list.
|
|
2714
|
+
* @param {?} delta Direction in which the user is moving.
|
|
2715
|
+
* @return {?}
|
|
2716
|
+
*/
|
|
2717
|
+
function (currentIndex, siblings, delta) {
|
|
2718
|
+
/** @type {?} */
|
|
2719
|
+
var isHorizontal = this._orientation === 'horizontal';
|
|
2720
|
+
/** @type {?} */
|
|
2721
|
+
var currentPosition = siblings[currentIndex].clientRect;
|
|
2722
|
+
/** @type {?} */
|
|
2723
|
+
var immediateSibling = siblings[currentIndex + delta * -1];
|
|
2724
|
+
/** @type {?} */
|
|
2725
|
+
var siblingOffset = currentPosition[isHorizontal ? 'width' : 'height'] * delta;
|
|
2726
|
+
if (immediateSibling) {
|
|
2727
|
+
/** @type {?} */
|
|
2728
|
+
var start = isHorizontal ? 'left' : 'top';
|
|
2729
|
+
/** @type {?} */
|
|
2730
|
+
var end = isHorizontal ? 'right' : 'bottom';
|
|
2731
|
+
// Get the spacing between the start of the current item and the end of the one immediately
|
|
2732
|
+
// after it in the direction in which the user is dragging, or vice versa. We add it to the
|
|
2733
|
+
// offset in order to push the element to where it will be when it's inline and is influenced
|
|
2734
|
+
// by the `margin` of its siblings.
|
|
2735
|
+
if (delta === -1) {
|
|
2736
|
+
siblingOffset -= immediateSibling.clientRect[start] - currentPosition[end];
|
|
2737
|
+
}
|
|
2738
|
+
else {
|
|
2739
|
+
siblingOffset += currentPosition[start] - immediateSibling.clientRect[end];
|
|
2740
|
+
}
|
|
2741
|
+
}
|
|
2742
|
+
return siblingOffset;
|
|
2743
|
+
};
|
|
2744
|
+
/**
|
|
2745
|
+
* Checks whether the pointer coordinates are close to the drop container.
|
|
2746
|
+
* @param pointerX Coordinates along the X axis.
|
|
2747
|
+
* @param pointerY Coordinates along the Y axis.
|
|
2748
|
+
*/
|
|
2749
|
+
/**
|
|
2750
|
+
* Checks whether the pointer coordinates are close to the drop container.
|
|
2751
|
+
* @private
|
|
2752
|
+
* @param {?} pointerX Coordinates along the X axis.
|
|
2753
|
+
* @param {?} pointerY Coordinates along the Y axis.
|
|
2754
|
+
* @return {?}
|
|
2755
|
+
*/
|
|
2756
|
+
DropListRef.prototype._isPointerNearDropContainer = /**
|
|
2757
|
+
* Checks whether the pointer coordinates are close to the drop container.
|
|
2758
|
+
* @private
|
|
2759
|
+
* @param {?} pointerX Coordinates along the X axis.
|
|
2760
|
+
* @param {?} pointerY Coordinates along the Y axis.
|
|
2761
|
+
* @return {?}
|
|
2762
|
+
*/
|
|
2763
|
+
function (pointerX, pointerY) {
|
|
2764
|
+
var _a = this._positionCache.self, top = _a.top, right = _a.right, bottom = _a.bottom, left = _a.left, width = _a.width, height = _a.height;
|
|
2765
|
+
/** @type {?} */
|
|
2766
|
+
var xThreshold = width * DROP_PROXIMITY_THRESHOLD;
|
|
2767
|
+
/** @type {?} */
|
|
2768
|
+
var yThreshold = height * DROP_PROXIMITY_THRESHOLD;
|
|
2769
|
+
return pointerY > top - yThreshold && pointerY < bottom + yThreshold &&
|
|
2770
|
+
pointerX > left - xThreshold && pointerX < right + xThreshold;
|
|
2771
|
+
};
|
|
2772
|
+
/**
|
|
2773
|
+
* Gets the offset in pixels by which the item that is being dragged should be moved.
|
|
2774
|
+
* @param currentPosition Current position of the item.
|
|
2775
|
+
* @param newPosition Position of the item where the current item should be moved.
|
|
2776
|
+
* @param delta Direction in which the user is moving.
|
|
2777
|
+
*/
|
|
2778
|
+
/**
|
|
2779
|
+
* Gets the offset in pixels by which the item that is being dragged should be moved.
|
|
2780
|
+
* @private
|
|
2781
|
+
* @param {?} currentPosition Current position of the item.
|
|
2782
|
+
* @param {?} newPosition Position of the item where the current item should be moved.
|
|
2783
|
+
* @param {?} delta Direction in which the user is moving.
|
|
2784
|
+
* @return {?}
|
|
2785
|
+
*/
|
|
2786
|
+
DropListRef.prototype._getItemOffsetPx = /**
|
|
2787
|
+
* Gets the offset in pixels by which the item that is being dragged should be moved.
|
|
2788
|
+
* @private
|
|
2789
|
+
* @param {?} currentPosition Current position of the item.
|
|
2790
|
+
* @param {?} newPosition Position of the item where the current item should be moved.
|
|
2791
|
+
* @param {?} delta Direction in which the user is moving.
|
|
2792
|
+
* @return {?}
|
|
2793
|
+
*/
|
|
2794
|
+
function (currentPosition, newPosition, delta) {
|
|
2795
|
+
/** @type {?} */
|
|
2796
|
+
var isHorizontal = this._orientation === 'horizontal';
|
|
2797
|
+
/** @type {?} */
|
|
2798
|
+
var itemOffset = isHorizontal ? newPosition.left - currentPosition.left :
|
|
2799
|
+
newPosition.top - currentPosition.top;
|
|
2800
|
+
// Account for differences in the item width/height.
|
|
2801
|
+
if (delta === -1) {
|
|
2802
|
+
itemOffset += isHorizontal ? newPosition.width - currentPosition.width :
|
|
2803
|
+
newPosition.height - currentPosition.height;
|
|
2804
|
+
}
|
|
2805
|
+
return itemOffset;
|
|
2806
|
+
};
|
|
2807
|
+
/**
|
|
2808
|
+
* Gets the index of an item in the drop container, based on the position of the user's pointer.
|
|
2809
|
+
* @param item Item that is being sorted.
|
|
2810
|
+
* @param pointerX Position of the user's pointer along the X axis.
|
|
2811
|
+
* @param pointerY Position of the user's pointer along the Y axis.
|
|
2812
|
+
* @param delta Direction in which the user is moving their pointer.
|
|
2813
|
+
*/
|
|
2814
|
+
/**
|
|
2815
|
+
* Gets the index of an item in the drop container, based on the position of the user's pointer.
|
|
2816
|
+
* @private
|
|
2817
|
+
* @param {?} item Item that is being sorted.
|
|
2818
|
+
* @param {?} pointerX Position of the user's pointer along the X axis.
|
|
2819
|
+
* @param {?} pointerY Position of the user's pointer along the Y axis.
|
|
2820
|
+
* @param {?=} delta Direction in which the user is moving their pointer.
|
|
2821
|
+
* @return {?}
|
|
2822
|
+
*/
|
|
2823
|
+
DropListRef.prototype._getItemIndexFromPointerPosition = /**
|
|
2824
|
+
* Gets the index of an item in the drop container, based on the position of the user's pointer.
|
|
2825
|
+
* @private
|
|
2826
|
+
* @param {?} item Item that is being sorted.
|
|
2827
|
+
* @param {?} pointerX Position of the user's pointer along the X axis.
|
|
2828
|
+
* @param {?} pointerY Position of the user's pointer along the Y axis.
|
|
2829
|
+
* @param {?=} delta Direction in which the user is moving their pointer.
|
|
2830
|
+
* @return {?}
|
|
2831
|
+
*/
|
|
2832
|
+
function (item, pointerX, pointerY, delta) {
|
|
2833
|
+
var _this = this;
|
|
2834
|
+
/** @type {?} */
|
|
2835
|
+
var isHorizontal = this._orientation === 'horizontal';
|
|
2836
|
+
return findIndex(this._positionCache.items, function (_a, _, array) {
|
|
2837
|
+
var drag = _a.drag, clientRect = _a.clientRect;
|
|
2838
|
+
if (drag === item) {
|
|
2839
|
+
// If there's only one item left in the container, it must be
|
|
2840
|
+
// the dragged item itself so we use it as a reference.
|
|
2841
|
+
return array.length < 2;
|
|
2842
|
+
}
|
|
2843
|
+
if (delta) {
|
|
2844
|
+
/** @type {?} */
|
|
2845
|
+
var direction = isHorizontal ? delta.x : delta.y;
|
|
2846
|
+
// If the user is still hovering over the same item as last time, and they didn't change
|
|
2847
|
+
// the direction in which they're dragging, we don't consider it a direction swap.
|
|
2848
|
+
if (drag === _this._previousSwap.drag && direction === _this._previousSwap.delta) {
|
|
2849
|
+
return false;
|
|
2850
|
+
}
|
|
2851
|
+
}
|
|
2852
|
+
return isHorizontal ?
|
|
2853
|
+
// Round these down since most browsers report client rects with
|
|
2854
|
+
// sub-pixel precision, whereas the pointer coordinates are rounded to pixels.
|
|
2855
|
+
pointerX >= Math.floor(clientRect.left) && pointerX <= Math.floor(clientRect.right) :
|
|
2856
|
+
pointerY >= Math.floor(clientRect.top) && pointerY <= Math.floor(clientRect.bottom);
|
|
2857
|
+
});
|
|
2858
|
+
};
|
|
2859
|
+
/**
|
|
2860
|
+
* Checks whether the user's pointer is positioned over the container.
|
|
2861
|
+
* @param x Pointer position along the X axis.
|
|
2862
|
+
* @param y Pointer position along the Y axis.
|
|
2863
|
+
*/
|
|
2864
|
+
/**
|
|
2865
|
+
* Checks whether the user's pointer is positioned over the container.
|
|
2866
|
+
* @param {?} x Pointer position along the X axis.
|
|
2867
|
+
* @param {?} y Pointer position along the Y axis.
|
|
2868
|
+
* @return {?}
|
|
2869
|
+
*/
|
|
2870
|
+
DropListRef.prototype._isOverContainer = /**
|
|
2871
|
+
* Checks whether the user's pointer is positioned over the container.
|
|
2872
|
+
* @param {?} x Pointer position along the X axis.
|
|
2873
|
+
* @param {?} y Pointer position along the Y axis.
|
|
2874
|
+
* @return {?}
|
|
2875
|
+
*/
|
|
2876
|
+
function (x, y) {
|
|
2877
|
+
return isInsideClientRect(this._positionCache.self, x, y);
|
|
2878
|
+
};
|
|
2879
|
+
/**
|
|
2001
2880
|
* Figures out whether an item should be moved into a sibling
|
|
2002
2881
|
* drop container, based on its current position.
|
|
2003
2882
|
* @param item Drag item that is being moved.
|
|
@@ -2012,7 +2891,7 @@ var CdkDropList = /** @class */ (function () {
|
|
|
2012
2891
|
* @param {?} y Position of the item along the Y axis.
|
|
2013
2892
|
* @return {?}
|
|
2014
2893
|
*/
|
|
2015
|
-
|
|
2894
|
+
DropListRef.prototype._getSiblingContainerFromPosition = /**
|
|
2016
2895
|
* Figures out whether an item should be moved into a sibling
|
|
2017
2896
|
* drop container, based on its current position.
|
|
2018
2897
|
* @param {?} item Drag item that is being moved.
|
|
@@ -2022,324 +2901,455 @@ var CdkDropList = /** @class */ (function () {
|
|
|
2022
2901
|
*/
|
|
2023
2902
|
function (item, x, y) {
|
|
2024
2903
|
/** @type {?} */
|
|
2025
|
-
var
|
|
2026
|
-
|
|
2904
|
+
var results = this._positionCache.siblings.filter(function (sibling) {
|
|
2905
|
+
return isInsideClientRect(sibling.clientRect, x, y);
|
|
2906
|
+
});
|
|
2907
|
+
// No drop containers are intersecting with the pointer.
|
|
2908
|
+
if (!results.length) {
|
|
2909
|
+
return null;
|
|
2910
|
+
}
|
|
2911
|
+
/** @type {?} */
|
|
2912
|
+
var elementFromPoint = this._document.elementFromPoint(x, y);
|
|
2913
|
+
// If there's no element at the pointer position, then
|
|
2914
|
+
// the client rect is probably scrolled out of the view.
|
|
2915
|
+
if (!elementFromPoint) {
|
|
2916
|
+
return null;
|
|
2917
|
+
}
|
|
2918
|
+
// The `ClientRect`, that we're using to find the container over which the user is
|
|
2919
|
+
// hovering, doesn't give us any information on whether the element has been scrolled
|
|
2920
|
+
// out of the view or whether it's overlapping with other containers. This means that
|
|
2921
|
+
// we could end up transferring the item into a container that's invisible or is positioned
|
|
2922
|
+
// below another one. We use the result from `elementFromPoint` to get the top-most element
|
|
2923
|
+
// at the pointer position and to find whether it's one of the intersecting drop containers.
|
|
2924
|
+
/** @type {?} */
|
|
2925
|
+
var result = results.find(function (sibling) {
|
|
2926
|
+
/** @type {?} */
|
|
2927
|
+
var element = sibling.drop.element.nativeElement;
|
|
2928
|
+
return element === elementFromPoint || element.contains(elementFromPoint);
|
|
2929
|
+
});
|
|
2027
2930
|
return result && result.drop.enterPredicate(item, result.drop) ? result.drop : null;
|
|
2028
2931
|
};
|
|
2932
|
+
return DropListRef;
|
|
2933
|
+
}());
|
|
2934
|
+
/**
|
|
2935
|
+
* Updates the top/left positions of a `ClientRect`, as well as their bottom/right counterparts.
|
|
2936
|
+
* @param {?} clientRect `ClientRect` that should be updated.
|
|
2937
|
+
* @param {?} top Amount to add to the `top` position.
|
|
2938
|
+
* @param {?} left Amount to add to the `left` position.
|
|
2939
|
+
* @return {?}
|
|
2940
|
+
*/
|
|
2941
|
+
function adjustClientRect(clientRect, top, left) {
|
|
2942
|
+
clientRect.top += top;
|
|
2943
|
+
clientRect.bottom = clientRect.top + clientRect.height;
|
|
2944
|
+
clientRect.left += left;
|
|
2945
|
+
clientRect.right = clientRect.left + clientRect.width;
|
|
2946
|
+
}
|
|
2947
|
+
/**
|
|
2948
|
+
* Finds the index of an item that matches a predicate function. Used as an equivalent
|
|
2949
|
+
* of `Array.prototype.find` which isn't part of the standard Google typings.
|
|
2950
|
+
* @template T
|
|
2951
|
+
* @param {?} array Array in which to look for matches.
|
|
2952
|
+
* @param {?} predicate Function used to determine whether an item is a match.
|
|
2953
|
+
* @return {?}
|
|
2954
|
+
*/
|
|
2955
|
+
function findIndex(array, predicate) {
|
|
2956
|
+
for (var i = 0; i < array.length; i++) {
|
|
2957
|
+
if (predicate(array[i], i, array)) {
|
|
2958
|
+
return i;
|
|
2959
|
+
}
|
|
2960
|
+
}
|
|
2961
|
+
return -1;
|
|
2962
|
+
}
|
|
2963
|
+
/**
|
|
2964
|
+
* Checks whether some coordinates are within a `ClientRect`.
|
|
2965
|
+
* @param {?} clientRect ClientRect that is being checked.
|
|
2966
|
+
* @param {?} x Coordinates along the X axis.
|
|
2967
|
+
* @param {?} y Coordinates along the Y axis.
|
|
2968
|
+
* @return {?}
|
|
2969
|
+
*/
|
|
2970
|
+
function isInsideClientRect(clientRect, x, y) {
|
|
2971
|
+
var top = clientRect.top, bottom = clientRect.bottom, left = clientRect.left, right = clientRect.right;
|
|
2972
|
+
return y >= top && y <= bottom && x >= left && x <= right;
|
|
2973
|
+
}
|
|
2974
|
+
|
|
2975
|
+
/**
|
|
2976
|
+
* @fileoverview added by tsickle
|
|
2977
|
+
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2978
|
+
*/
|
|
2979
|
+
/**
|
|
2980
|
+
* Counter used to generate unique ids for drop zones.
|
|
2981
|
+
* @type {?}
|
|
2982
|
+
*/
|
|
2983
|
+
var _uniqueIdCounter$1 = 0;
|
|
2984
|
+
var ɵ0 = undefined;
|
|
2985
|
+
// @breaking-change 8.0.0 `CdkDropList` implements `CdkDropListContainer` for backwards
|
|
2986
|
+
// compatiblity. The implements clause, as well as all the methods that it enforces can
|
|
2987
|
+
// be removed when `CdkDropListContainer` is deleted.
|
|
2988
|
+
/**
|
|
2989
|
+
* Container that wraps a set of draggable items.
|
|
2990
|
+
* @template T
|
|
2991
|
+
*/
|
|
2992
|
+
var CdkDropList = /** @class */ (function () {
|
|
2993
|
+
function CdkDropList(element, dragDropRegistry, _changeDetectorRef, dir, _group,
|
|
2994
|
+
// @breaking-change 8.0.0 `_document` parameter to be made required.
|
|
2995
|
+
_document) {
|
|
2996
|
+
var _this = this;
|
|
2997
|
+
this.element = element;
|
|
2998
|
+
this._changeDetectorRef = _changeDetectorRef;
|
|
2999
|
+
this._group = _group;
|
|
3000
|
+
/**
|
|
3001
|
+
* Other draggable containers that this container is connected to and into which the
|
|
3002
|
+
* container's items can be transferred. Can either be references to other drop containers,
|
|
3003
|
+
* or their unique IDs.
|
|
3004
|
+
*/
|
|
3005
|
+
this.connectedTo = [];
|
|
3006
|
+
/**
|
|
3007
|
+
* Direction in which the list is oriented.
|
|
3008
|
+
*/
|
|
3009
|
+
this.orientation = 'vertical';
|
|
3010
|
+
/**
|
|
3011
|
+
* Unique ID for the drop zone. Can be used as a reference
|
|
3012
|
+
* in the `connectedTo` of another `CdkDropList`.
|
|
3013
|
+
*/
|
|
3014
|
+
this.id = "cdk-drop-list-" + _uniqueIdCounter$1++;
|
|
3015
|
+
this._disabled = false;
|
|
3016
|
+
/**
|
|
3017
|
+
* Function that is used to determine whether an item
|
|
3018
|
+
* is allowed to be moved into a drop container.
|
|
3019
|
+
*/
|
|
3020
|
+
this.enterPredicate = function () { return true; };
|
|
3021
|
+
/**
|
|
3022
|
+
* Emits when the user drops an item inside the container.
|
|
3023
|
+
*/
|
|
3024
|
+
this.dropped = new EventEmitter();
|
|
3025
|
+
/**
|
|
3026
|
+
* Emits when the user has moved a new drag item into this container.
|
|
3027
|
+
*/
|
|
3028
|
+
this.entered = new EventEmitter();
|
|
3029
|
+
/**
|
|
3030
|
+
* Emits when the user removes an item from the container
|
|
3031
|
+
* by dragging it into another container.
|
|
3032
|
+
*/
|
|
3033
|
+
this.exited = new EventEmitter();
|
|
3034
|
+
/**
|
|
3035
|
+
* Emits as the user is swapping items while actively dragging.
|
|
3036
|
+
*/
|
|
3037
|
+
this.sorted = new EventEmitter();
|
|
3038
|
+
// @breaking-change 8.0.0 Remove || once `_document` parameter is required.
|
|
3039
|
+
/** @type {?} */
|
|
3040
|
+
var ref = this._dropListRef = new DropListRef(element, dragDropRegistry, _document || document, dir);
|
|
3041
|
+
ref.data = this;
|
|
3042
|
+
ref.enterPredicate = function (drag, drop) {
|
|
3043
|
+
return _this.enterPredicate(drag.data, drop.data);
|
|
3044
|
+
};
|
|
3045
|
+
this._syncInputs(ref);
|
|
3046
|
+
this._proxyEvents(ref);
|
|
3047
|
+
CdkDropList._dropLists.push(this);
|
|
3048
|
+
if (_group) {
|
|
3049
|
+
_group._items.add(this);
|
|
3050
|
+
}
|
|
3051
|
+
}
|
|
3052
|
+
Object.defineProperty(CdkDropList.prototype, "disabled", {
|
|
3053
|
+
/** Whether starting a dragging sequence from this container is disabled. */
|
|
3054
|
+
get: /**
|
|
3055
|
+
* Whether starting a dragging sequence from this container is disabled.
|
|
3056
|
+
* @return {?}
|
|
3057
|
+
*/
|
|
3058
|
+
function () {
|
|
3059
|
+
return this._disabled || (!!this._group && this._group.disabled);
|
|
3060
|
+
},
|
|
3061
|
+
set: /**
|
|
3062
|
+
* @param {?} value
|
|
3063
|
+
* @return {?}
|
|
3064
|
+
*/
|
|
3065
|
+
function (value) {
|
|
3066
|
+
this._disabled = coerceBooleanProperty(value);
|
|
3067
|
+
},
|
|
3068
|
+
enumerable: true,
|
|
3069
|
+
configurable: true
|
|
3070
|
+
});
|
|
2029
3071
|
/**
|
|
2030
|
-
*
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
* @
|
|
3072
|
+
* @return {?}
|
|
3073
|
+
*/
|
|
3074
|
+
CdkDropList.prototype.ngOnDestroy = /**
|
|
3075
|
+
* @return {?}
|
|
2034
3076
|
*/
|
|
3077
|
+
function () {
|
|
3078
|
+
/** @type {?} */
|
|
3079
|
+
var index = CdkDropList._dropLists.indexOf(this);
|
|
3080
|
+
this._dropListRef.dispose();
|
|
3081
|
+
if (index > -1) {
|
|
3082
|
+
CdkDropList._dropLists.splice(index, 1);
|
|
3083
|
+
}
|
|
3084
|
+
if (this._group) {
|
|
3085
|
+
this._group._items.delete(this);
|
|
3086
|
+
}
|
|
3087
|
+
};
|
|
3088
|
+
/** Starts dragging an item. */
|
|
2035
3089
|
/**
|
|
2036
|
-
*
|
|
2037
|
-
* after it was moved out into another container.
|
|
2038
|
-
* @param {?} x Position of the item along the X axis.
|
|
2039
|
-
* @param {?} y Position of the item along the Y axis.
|
|
3090
|
+
* Starts dragging an item.
|
|
2040
3091
|
* @return {?}
|
|
2041
3092
|
*/
|
|
2042
|
-
CdkDropList.prototype.
|
|
2043
|
-
*
|
|
2044
|
-
* after it was moved out into another container.
|
|
2045
|
-
* @param {?} x Position of the item along the X axis.
|
|
2046
|
-
* @param {?} y Position of the item along the Y axis.
|
|
3093
|
+
CdkDropList.prototype.start = /**
|
|
3094
|
+
* Starts dragging an item.
|
|
2047
3095
|
* @return {?}
|
|
2048
3096
|
*/
|
|
2049
|
-
function (
|
|
2050
|
-
|
|
3097
|
+
function () {
|
|
3098
|
+
this._dropListRef.start();
|
|
2051
3099
|
};
|
|
2052
|
-
/** Refreshes the position cache of the items and sibling containers. */
|
|
2053
3100
|
/**
|
|
2054
|
-
*
|
|
2055
|
-
* @
|
|
3101
|
+
* Drops an item into this container.
|
|
3102
|
+
* @param item Item being dropped into the container.
|
|
3103
|
+
* @param currentIndex Index at which the item should be inserted.
|
|
3104
|
+
* @param previousContainer Container from which the item got dragged in.
|
|
3105
|
+
* @param isPointerOverContainer Whether the user's pointer was over the
|
|
3106
|
+
* container when the item was dropped.
|
|
3107
|
+
*/
|
|
3108
|
+
/**
|
|
3109
|
+
* Drops an item into this container.
|
|
3110
|
+
* @param {?} item Item being dropped into the container.
|
|
3111
|
+
* @param {?} currentIndex Index at which the item should be inserted.
|
|
3112
|
+
* @param {?} previousContainer Container from which the item got dragged in.
|
|
3113
|
+
* @param {?} isPointerOverContainer Whether the user's pointer was over the
|
|
3114
|
+
* container when the item was dropped.
|
|
2056
3115
|
* @return {?}
|
|
2057
3116
|
*/
|
|
2058
|
-
CdkDropList.prototype.
|
|
2059
|
-
*
|
|
2060
|
-
* @
|
|
3117
|
+
CdkDropList.prototype.drop = /**
|
|
3118
|
+
* Drops an item into this container.
|
|
3119
|
+
* @param {?} item Item being dropped into the container.
|
|
3120
|
+
* @param {?} currentIndex Index at which the item should be inserted.
|
|
3121
|
+
* @param {?} previousContainer Container from which the item got dragged in.
|
|
3122
|
+
* @param {?} isPointerOverContainer Whether the user's pointer was over the
|
|
3123
|
+
* container when the item was dropped.
|
|
2061
3124
|
* @return {?}
|
|
2062
3125
|
*/
|
|
2063
|
-
function () {
|
|
2064
|
-
|
|
2065
|
-
/** @type {?} */
|
|
2066
|
-
var isHorizontal = this.orientation === 'horizontal';
|
|
2067
|
-
this._positionCache.self = this.element.nativeElement.getBoundingClientRect();
|
|
2068
|
-
this._positionCache.items = this._activeDraggables
|
|
2069
|
-
.map(function (drag) {
|
|
2070
|
-
/** @type {?} */
|
|
2071
|
-
var elementToMeasure = _this._dragDropRegistry.isDragging(drag) ?
|
|
2072
|
-
// If the element is being dragged, we have to measure the
|
|
2073
|
-
// placeholder, because the element is hidden.
|
|
2074
|
-
drag.getPlaceholderElement() :
|
|
2075
|
-
drag.getRootElement();
|
|
2076
|
-
/** @type {?} */
|
|
2077
|
-
var clientRect = elementToMeasure.getBoundingClientRect();
|
|
2078
|
-
return {
|
|
2079
|
-
drag: drag,
|
|
2080
|
-
offset: 0,
|
|
2081
|
-
// We need to clone the `clientRect` here, because all the values on it are readonly
|
|
2082
|
-
// and we need to be able to update them. Also we can't use a spread here, because
|
|
2083
|
-
// the values on a `ClientRect` aren't own properties. See:
|
|
2084
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect#Notes
|
|
2085
|
-
clientRect: {
|
|
2086
|
-
top: clientRect.top,
|
|
2087
|
-
right: clientRect.right,
|
|
2088
|
-
bottom: clientRect.bottom,
|
|
2089
|
-
left: clientRect.left,
|
|
2090
|
-
width: clientRect.width,
|
|
2091
|
-
height: clientRect.height
|
|
2092
|
-
}
|
|
2093
|
-
};
|
|
2094
|
-
})
|
|
2095
|
-
.sort(function (a, b) {
|
|
2096
|
-
return isHorizontal ? a.clientRect.left - b.clientRect.left :
|
|
2097
|
-
a.clientRect.top - b.clientRect.top;
|
|
2098
|
-
});
|
|
2099
|
-
this._positionCache.siblings = this._getConnectedLists().map(function (drop) { return ({
|
|
2100
|
-
drop: drop,
|
|
2101
|
-
clientRect: drop.element.nativeElement.getBoundingClientRect()
|
|
2102
|
-
}); });
|
|
3126
|
+
function (item, currentIndex, previousContainer, isPointerOverContainer) {
|
|
3127
|
+
this._dropListRef.drop(item._dragRef, currentIndex, ((/** @type {?} */ (previousContainer)))._dropListRef, isPointerOverContainer);
|
|
2103
3128
|
};
|
|
2104
|
-
/** Resets the container to its initial state. */
|
|
2105
3129
|
/**
|
|
2106
|
-
*
|
|
2107
|
-
* @
|
|
3130
|
+
* Emits an event to indicate that the user moved an item into the container.
|
|
3131
|
+
* @param item Item that was moved into the container.
|
|
3132
|
+
* @param pointerX Position of the item along the X axis.
|
|
3133
|
+
* @param pointerY Position of the item along the Y axis.
|
|
3134
|
+
*/
|
|
3135
|
+
/**
|
|
3136
|
+
* Emits an event to indicate that the user moved an item into the container.
|
|
3137
|
+
* @param {?} item Item that was moved into the container.
|
|
3138
|
+
* @param {?} pointerX Position of the item along the X axis.
|
|
3139
|
+
* @param {?} pointerY Position of the item along the Y axis.
|
|
2108
3140
|
* @return {?}
|
|
2109
3141
|
*/
|
|
2110
|
-
CdkDropList.prototype.
|
|
2111
|
-
*
|
|
2112
|
-
* @
|
|
3142
|
+
CdkDropList.prototype.enter = /**
|
|
3143
|
+
* Emits an event to indicate that the user moved an item into the container.
|
|
3144
|
+
* @param {?} item Item that was moved into the container.
|
|
3145
|
+
* @param {?} pointerX Position of the item along the X axis.
|
|
3146
|
+
* @param {?} pointerY Position of the item along the Y axis.
|
|
2113
3147
|
* @return {?}
|
|
2114
3148
|
*/
|
|
2115
|
-
function () {
|
|
2116
|
-
this.
|
|
2117
|
-
// TODO(crisbeto): may have to wait for the animations to finish.
|
|
2118
|
-
this._activeDraggables.forEach(function (item) { return item.getRootElement().style.transform = ''; });
|
|
2119
|
-
this._activeDraggables = [];
|
|
2120
|
-
this._positionCache.items = [];
|
|
2121
|
-
this._positionCache.siblings = [];
|
|
2122
|
-
this._previousSwap.drag = null;
|
|
2123
|
-
this._previousSwap.delta = 0;
|
|
3149
|
+
function (item, pointerX, pointerY) {
|
|
3150
|
+
this._dropListRef.enter(item._dragRef, pointerX, pointerY);
|
|
2124
3151
|
};
|
|
2125
3152
|
/**
|
|
2126
|
-
*
|
|
2127
|
-
* @param
|
|
2128
|
-
* @param top Amount to add to the `top` position.
|
|
2129
|
-
* @param left Amount to add to the `left` position.
|
|
3153
|
+
* Removes an item from the container after it was dragged into another container by the user.
|
|
3154
|
+
* @param item Item that was dragged out.
|
|
2130
3155
|
*/
|
|
2131
3156
|
/**
|
|
2132
|
-
*
|
|
2133
|
-
* @
|
|
2134
|
-
* @param {?} clientRect `ClientRect` that should be updated.
|
|
2135
|
-
* @param {?} top Amount to add to the `top` position.
|
|
2136
|
-
* @param {?} left Amount to add to the `left` position.
|
|
3157
|
+
* Removes an item from the container after it was dragged into another container by the user.
|
|
3158
|
+
* @param {?} item Item that was dragged out.
|
|
2137
3159
|
* @return {?}
|
|
2138
3160
|
*/
|
|
2139
|
-
CdkDropList.prototype.
|
|
2140
|
-
*
|
|
2141
|
-
* @
|
|
2142
|
-
* @param {?} clientRect `ClientRect` that should be updated.
|
|
2143
|
-
* @param {?} top Amount to add to the `top` position.
|
|
2144
|
-
* @param {?} left Amount to add to the `left` position.
|
|
3161
|
+
CdkDropList.prototype.exit = /**
|
|
3162
|
+
* Removes an item from the container after it was dragged into another container by the user.
|
|
3163
|
+
* @param {?} item Item that was dragged out.
|
|
2145
3164
|
* @return {?}
|
|
2146
3165
|
*/
|
|
2147
|
-
function (
|
|
2148
|
-
|
|
2149
|
-
clientRect.bottom = clientRect.top + clientRect.height;
|
|
2150
|
-
clientRect.left += left;
|
|
2151
|
-
clientRect.right = clientRect.left + clientRect.width;
|
|
3166
|
+
function (item) {
|
|
3167
|
+
this._dropListRef.exit(item._dragRef);
|
|
2152
3168
|
};
|
|
2153
3169
|
/**
|
|
2154
|
-
*
|
|
2155
|
-
* @param item Item
|
|
2156
|
-
* @param pointerX Position of the user's pointer along the X axis.
|
|
2157
|
-
* @param pointerY Position of the user's pointer along the Y axis.
|
|
2158
|
-
* @param delta Direction in which the user is moving their pointer.
|
|
3170
|
+
* Figures out the index of an item in the container.
|
|
3171
|
+
* @param item Item whose index should be determined.
|
|
2159
3172
|
*/
|
|
2160
3173
|
/**
|
|
2161
|
-
*
|
|
2162
|
-
* @
|
|
2163
|
-
* @param {?} item Item that is being sorted.
|
|
2164
|
-
* @param {?} pointerX Position of the user's pointer along the X axis.
|
|
2165
|
-
* @param {?} pointerY Position of the user's pointer along the Y axis.
|
|
2166
|
-
* @param {?=} delta Direction in which the user is moving their pointer.
|
|
3174
|
+
* Figures out the index of an item in the container.
|
|
3175
|
+
* @param {?} item Item whose index should be determined.
|
|
2167
3176
|
* @return {?}
|
|
2168
3177
|
*/
|
|
2169
|
-
CdkDropList.prototype.
|
|
2170
|
-
*
|
|
2171
|
-
* @
|
|
2172
|
-
* @param {?} item Item that is being sorted.
|
|
2173
|
-
* @param {?} pointerX Position of the user's pointer along the X axis.
|
|
2174
|
-
* @param {?} pointerY Position of the user's pointer along the Y axis.
|
|
2175
|
-
* @param {?=} delta Direction in which the user is moving their pointer.
|
|
3178
|
+
CdkDropList.prototype.getItemIndex = /**
|
|
3179
|
+
* Figures out the index of an item in the container.
|
|
3180
|
+
* @param {?} item Item whose index should be determined.
|
|
2176
3181
|
* @return {?}
|
|
2177
3182
|
*/
|
|
2178
|
-
function (item
|
|
2179
|
-
|
|
2180
|
-
/** @type {?} */
|
|
2181
|
-
var isHorizontal = this.orientation === 'horizontal';
|
|
2182
|
-
return findIndex(this._positionCache.items, function (_a, _, array) {
|
|
2183
|
-
var drag = _a.drag, clientRect = _a.clientRect;
|
|
2184
|
-
if (drag === item) {
|
|
2185
|
-
// If there's only one item left in the container, it must be
|
|
2186
|
-
// the dragged item itself so we use it as a reference.
|
|
2187
|
-
return array.length < 2;
|
|
2188
|
-
}
|
|
2189
|
-
if (delta) {
|
|
2190
|
-
/** @type {?} */
|
|
2191
|
-
var direction = isHorizontal ? delta.x : delta.y;
|
|
2192
|
-
// If the user is still hovering over the same item as last time, and they didn't change
|
|
2193
|
-
// the direction in which they're dragging, we don't consider it a direction swap.
|
|
2194
|
-
if (drag === _this._previousSwap.drag && direction === _this._previousSwap.delta) {
|
|
2195
|
-
return false;
|
|
2196
|
-
}
|
|
2197
|
-
}
|
|
2198
|
-
return isHorizontal ?
|
|
2199
|
-
// Round these down since most browsers report client rects with
|
|
2200
|
-
// sub-pixel precision, whereas the pointer coordinates are rounded to pixels.
|
|
2201
|
-
pointerX >= Math.floor(clientRect.left) && pointerX <= Math.floor(clientRect.right) :
|
|
2202
|
-
pointerY >= Math.floor(clientRect.top) && pointerY <= Math.floor(clientRect.bottom);
|
|
2203
|
-
});
|
|
3183
|
+
function (item) {
|
|
3184
|
+
return this._dropListRef.getItemIndex(item._dragRef);
|
|
2204
3185
|
};
|
|
2205
3186
|
/**
|
|
2206
|
-
*
|
|
2207
|
-
* @param
|
|
2208
|
-
* @param
|
|
3187
|
+
* Sorts an item inside the container based on its position.
|
|
3188
|
+
* @param item Item to be sorted.
|
|
3189
|
+
* @param pointerX Position of the item along the X axis.
|
|
3190
|
+
* @param pointerY Position of the item along the Y axis.
|
|
3191
|
+
* @param pointerDelta Direction in which the pointer is moving along each axis.
|
|
2209
3192
|
*/
|
|
2210
3193
|
/**
|
|
2211
|
-
*
|
|
2212
|
-
* @
|
|
2213
|
-
* @param {?} pointerX
|
|
2214
|
-
* @param {?} pointerY
|
|
3194
|
+
* Sorts an item inside the container based on its position.
|
|
3195
|
+
* @param {?} item Item to be sorted.
|
|
3196
|
+
* @param {?} pointerX Position of the item along the X axis.
|
|
3197
|
+
* @param {?} pointerY Position of the item along the Y axis.
|
|
3198
|
+
* @param {?} pointerDelta Direction in which the pointer is moving along each axis.
|
|
2215
3199
|
* @return {?}
|
|
2216
3200
|
*/
|
|
2217
|
-
CdkDropList.prototype.
|
|
2218
|
-
*
|
|
2219
|
-
* @
|
|
2220
|
-
* @param {?} pointerX
|
|
2221
|
-
* @param {?} pointerY
|
|
3201
|
+
CdkDropList.prototype._sortItem = /**
|
|
3202
|
+
* Sorts an item inside the container based on its position.
|
|
3203
|
+
* @param {?} item Item to be sorted.
|
|
3204
|
+
* @param {?} pointerX Position of the item along the X axis.
|
|
3205
|
+
* @param {?} pointerY Position of the item along the Y axis.
|
|
3206
|
+
* @param {?} pointerDelta Direction in which the pointer is moving along each axis.
|
|
2222
3207
|
* @return {?}
|
|
2223
3208
|
*/
|
|
2224
|
-
function (pointerX, pointerY) {
|
|
2225
|
-
|
|
2226
|
-
/** @type {?} */
|
|
2227
|
-
var xThreshold = width * DROP_PROXIMITY_THRESHOLD;
|
|
2228
|
-
/** @type {?} */
|
|
2229
|
-
var yThreshold = height * DROP_PROXIMITY_THRESHOLD;
|
|
2230
|
-
return pointerY > top - yThreshold && pointerY < bottom + yThreshold &&
|
|
2231
|
-
pointerX > left - xThreshold && pointerX < right + xThreshold;
|
|
3209
|
+
function (item, pointerX, pointerY, pointerDelta) {
|
|
3210
|
+
return this._dropListRef._sortItem(item._dragRef, pointerX, pointerY, pointerDelta);
|
|
2232
3211
|
};
|
|
2233
3212
|
/**
|
|
2234
|
-
*
|
|
2235
|
-
*
|
|
2236
|
-
* @param
|
|
2237
|
-
* @param
|
|
3213
|
+
* Figures out whether an item should be moved into a sibling
|
|
3214
|
+
* drop container, based on its current position.
|
|
3215
|
+
* @param item Drag item that is being moved.
|
|
3216
|
+
* @param x Position of the item along the X axis.
|
|
3217
|
+
* @param y Position of the item along the Y axis.
|
|
2238
3218
|
*/
|
|
2239
3219
|
/**
|
|
2240
|
-
*
|
|
2241
|
-
*
|
|
2242
|
-
* @param {?}
|
|
2243
|
-
* @param {?}
|
|
2244
|
-
* @param {?}
|
|
3220
|
+
* Figures out whether an item should be moved into a sibling
|
|
3221
|
+
* drop container, based on its current position.
|
|
3222
|
+
* @param {?} item Drag item that is being moved.
|
|
3223
|
+
* @param {?} x Position of the item along the X axis.
|
|
3224
|
+
* @param {?} y Position of the item along the Y axis.
|
|
2245
3225
|
* @return {?}
|
|
2246
3226
|
*/
|
|
2247
|
-
CdkDropList.prototype.
|
|
2248
|
-
*
|
|
2249
|
-
*
|
|
2250
|
-
* @param {?}
|
|
2251
|
-
* @param {?}
|
|
2252
|
-
* @param {?}
|
|
3227
|
+
CdkDropList.prototype._getSiblingContainerFromPosition = /**
|
|
3228
|
+
* Figures out whether an item should be moved into a sibling
|
|
3229
|
+
* drop container, based on its current position.
|
|
3230
|
+
* @param {?} item Drag item that is being moved.
|
|
3231
|
+
* @param {?} x Position of the item along the X axis.
|
|
3232
|
+
* @param {?} y Position of the item along the Y axis.
|
|
2253
3233
|
* @return {?}
|
|
2254
3234
|
*/
|
|
2255
|
-
function (
|
|
2256
|
-
/** @type {?} */
|
|
2257
|
-
var isHorizontal = this.orientation === 'horizontal';
|
|
3235
|
+
function (item, x, y) {
|
|
2258
3236
|
/** @type {?} */
|
|
2259
|
-
var
|
|
2260
|
-
|
|
2261
|
-
// Account for differences in the item width/height.
|
|
2262
|
-
if (delta === -1) {
|
|
2263
|
-
itemOffset += isHorizontal ? newPosition.width - currentPosition.width :
|
|
2264
|
-
newPosition.height - currentPosition.height;
|
|
2265
|
-
}
|
|
2266
|
-
return itemOffset;
|
|
3237
|
+
var result = this._dropListRef._getSiblingContainerFromPosition(item._dragRef, x, y);
|
|
3238
|
+
return result ? result.data : null;
|
|
2267
3239
|
};
|
|
2268
3240
|
/**
|
|
2269
|
-
*
|
|
2270
|
-
* @param
|
|
2271
|
-
* @param
|
|
2272
|
-
* @param delta Direction in which the user is moving.
|
|
3241
|
+
* Checks whether the user's pointer is positioned over the container.
|
|
3242
|
+
* @param x Pointer position along the X axis.
|
|
3243
|
+
* @param y Pointer position along the Y axis.
|
|
2273
3244
|
*/
|
|
2274
3245
|
/**
|
|
2275
|
-
*
|
|
3246
|
+
* Checks whether the user's pointer is positioned over the container.
|
|
3247
|
+
* @param {?} x Pointer position along the X axis.
|
|
3248
|
+
* @param {?} y Pointer position along the Y axis.
|
|
3249
|
+
* @return {?}
|
|
3250
|
+
*/
|
|
3251
|
+
CdkDropList.prototype._isOverContainer = /**
|
|
3252
|
+
* Checks whether the user's pointer is positioned over the container.
|
|
3253
|
+
* @param {?} x Pointer position along the X axis.
|
|
3254
|
+
* @param {?} y Pointer position along the Y axis.
|
|
3255
|
+
* @return {?}
|
|
3256
|
+
*/
|
|
3257
|
+
function (x, y) {
|
|
3258
|
+
return this._dropListRef._isOverContainer(x, y);
|
|
3259
|
+
};
|
|
3260
|
+
/** Syncs the inputs of the CdkDropList with the options of the underlying DropListRef. */
|
|
3261
|
+
/**
|
|
3262
|
+
* Syncs the inputs of the CdkDropList with the options of the underlying DropListRef.
|
|
2276
3263
|
* @private
|
|
2277
|
-
* @param {?}
|
|
2278
|
-
* @param {?} siblings All of the items in the list.
|
|
2279
|
-
* @param {?} delta Direction in which the user is moving.
|
|
3264
|
+
* @param {?} ref
|
|
2280
3265
|
* @return {?}
|
|
2281
3266
|
*/
|
|
2282
|
-
CdkDropList.prototype.
|
|
2283
|
-
*
|
|
3267
|
+
CdkDropList.prototype._syncInputs = /**
|
|
3268
|
+
* Syncs the inputs of the CdkDropList with the options of the underlying DropListRef.
|
|
2284
3269
|
* @private
|
|
2285
|
-
* @param {?}
|
|
2286
|
-
* @param {?} siblings All of the items in the list.
|
|
2287
|
-
* @param {?} delta Direction in which the user is moving.
|
|
3270
|
+
* @param {?} ref
|
|
2288
3271
|
* @return {?}
|
|
2289
3272
|
*/
|
|
2290
|
-
function (
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
/** @type {?} */
|
|
2294
|
-
var currentPosition = siblings[currentIndex].clientRect;
|
|
2295
|
-
/** @type {?} */
|
|
2296
|
-
var immediateSibling = siblings[currentIndex + delta * -1];
|
|
2297
|
-
/** @type {?} */
|
|
2298
|
-
var siblingOffset = currentPosition[isHorizontal ? 'width' : 'height'] * delta;
|
|
2299
|
-
if (immediateSibling) {
|
|
2300
|
-
/** @type {?} */
|
|
2301
|
-
var start = isHorizontal ? 'left' : 'top';
|
|
3273
|
+
function (ref) {
|
|
3274
|
+
var _this = this;
|
|
3275
|
+
ref.beforeStarted.subscribe(function () {
|
|
2302
3276
|
/** @type {?} */
|
|
2303
|
-
var
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
3277
|
+
var siblings = coerceArray(_this.connectedTo).map(function (drop) {
|
|
3278
|
+
return typeof drop === 'string' ?
|
|
3279
|
+
(/** @type {?} */ (CdkDropList._dropLists.find(function (list) { return list.id === drop; }))) : drop;
|
|
3280
|
+
});
|
|
3281
|
+
if (_this._group) {
|
|
3282
|
+
_this._group._items.forEach(function (drop) {
|
|
3283
|
+
if (siblings.indexOf(drop) === -1) {
|
|
3284
|
+
siblings.push(drop);
|
|
3285
|
+
}
|
|
3286
|
+
});
|
|
2313
3287
|
}
|
|
2314
|
-
|
|
2315
|
-
|
|
3288
|
+
ref.lockAxis = _this.lockAxis;
|
|
3289
|
+
ref
|
|
3290
|
+
.connectedTo(siblings.filter(function (drop) { return drop && drop !== _this; }).map(function (list) { return list._dropListRef; }))
|
|
3291
|
+
.withOrientation(_this.orientation)
|
|
3292
|
+
.withItems(_this._draggables.map(function (drag) { return drag._dragRef; }));
|
|
3293
|
+
});
|
|
2316
3294
|
};
|
|
2317
|
-
/** Gets an array of unique drop lists that the current list is connected to. */
|
|
2318
3295
|
/**
|
|
2319
|
-
*
|
|
3296
|
+
* Proxies the events from a DropListRef to events that
|
|
3297
|
+
* match the interfaces of the CdkDropList outputs.
|
|
3298
|
+
*/
|
|
3299
|
+
/**
|
|
3300
|
+
* Proxies the events from a DropListRef to events that
|
|
3301
|
+
* match the interfaces of the CdkDropList outputs.
|
|
2320
3302
|
* @private
|
|
3303
|
+
* @param {?} ref
|
|
2321
3304
|
* @return {?}
|
|
2322
3305
|
*/
|
|
2323
|
-
CdkDropList.prototype.
|
|
2324
|
-
*
|
|
3306
|
+
CdkDropList.prototype._proxyEvents = /**
|
|
3307
|
+
* Proxies the events from a DropListRef to events that
|
|
3308
|
+
* match the interfaces of the CdkDropList outputs.
|
|
2325
3309
|
* @private
|
|
3310
|
+
* @param {?} ref
|
|
2326
3311
|
* @return {?}
|
|
2327
3312
|
*/
|
|
2328
|
-
function () {
|
|
3313
|
+
function (ref) {
|
|
2329
3314
|
var _this = this;
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
return typeof drop === 'string' ? (/** @type {?} */ (_this._dragDropRegistry.getDropContainer(drop))) : drop;
|
|
3315
|
+
ref.beforeStarted.subscribe(function () {
|
|
3316
|
+
_this._changeDetectorRef.markForCheck();
|
|
2333
3317
|
});
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
}
|
|
3318
|
+
ref.entered.subscribe(function (event) {
|
|
3319
|
+
_this.entered.emit({
|
|
3320
|
+
container: _this,
|
|
3321
|
+
item: event.item.data
|
|
2339
3322
|
});
|
|
2340
|
-
}
|
|
2341
|
-
|
|
3323
|
+
});
|
|
3324
|
+
ref.exited.subscribe(function (event) {
|
|
3325
|
+
_this.exited.emit({
|
|
3326
|
+
container: _this,
|
|
3327
|
+
item: event.item.data
|
|
3328
|
+
});
|
|
3329
|
+
});
|
|
3330
|
+
ref.sorted.subscribe(function (event) {
|
|
3331
|
+
_this.sorted.emit({
|
|
3332
|
+
previousIndex: event.previousIndex,
|
|
3333
|
+
currentIndex: event.currentIndex,
|
|
3334
|
+
container: _this,
|
|
3335
|
+
item: event.item.data
|
|
3336
|
+
});
|
|
3337
|
+
});
|
|
3338
|
+
ref.dropped.subscribe(function (event) {
|
|
3339
|
+
_this.dropped.emit({
|
|
3340
|
+
previousIndex: event.previousIndex,
|
|
3341
|
+
currentIndex: event.currentIndex,
|
|
3342
|
+
previousContainer: event.previousContainer.data,
|
|
3343
|
+
container: event.container.data,
|
|
3344
|
+
item: event.item.data,
|
|
3345
|
+
isPointerOverContainer: event.isPointerOverContainer
|
|
3346
|
+
});
|
|
3347
|
+
});
|
|
2342
3348
|
};
|
|
3349
|
+
/**
|
|
3350
|
+
* Keeps track of the drop lists that are currently on the page.
|
|
3351
|
+
*/
|
|
3352
|
+
CdkDropList._dropLists = [];
|
|
2343
3353
|
CdkDropList.decorators = [
|
|
2344
3354
|
{ type: Directive, args: [{
|
|
2345
3355
|
selector: '[cdkDropList], cdk-drop-list',
|
|
@@ -2352,7 +3362,8 @@ var CdkDropList = /** @class */ (function () {
|
|
|
2352
3362
|
host: {
|
|
2353
3363
|
'class': 'cdk-drop-list',
|
|
2354
3364
|
'[id]': 'id',
|
|
2355
|
-
'[class.cdk-drop-list-dragging]': '
|
|
3365
|
+
'[class.cdk-drop-list-dragging]': '_dropListRef.isDragging()',
|
|
3366
|
+
'[class.cdk-drop-list-receiving]': '_dropListRef.isReceiving()',
|
|
2356
3367
|
}
|
|
2357
3368
|
},] },
|
|
2358
3369
|
];
|
|
@@ -2362,7 +3373,8 @@ var CdkDropList = /** @class */ (function () {
|
|
|
2362
3373
|
{ type: DragDropRegistry },
|
|
2363
3374
|
{ type: ChangeDetectorRef },
|
|
2364
3375
|
{ type: Directionality, decorators: [{ type: Optional }] },
|
|
2365
|
-
{ type: CdkDropListGroup, decorators: [{ type: Optional }, { type: SkipSelf }] }
|
|
3376
|
+
{ type: CdkDropListGroup, decorators: [{ type: Optional }, { type: SkipSelf }] },
|
|
3377
|
+
{ type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [DOCUMENT,] }] }
|
|
2366
3378
|
]; };
|
|
2367
3379
|
CdkDropList.propDecorators = {
|
|
2368
3380
|
_draggables: [{ type: ContentChildren, args: [forwardRef(function () { return CdkDrag; }),] }],
|
|
@@ -2380,38 +3392,6 @@ var CdkDropList = /** @class */ (function () {
|
|
|
2380
3392
|
};
|
|
2381
3393
|
return CdkDropList;
|
|
2382
3394
|
}());
|
|
2383
|
-
/**
|
|
2384
|
-
* Finds the index of an item that matches a predicate function. Used as an equivalent
|
|
2385
|
-
* of `Array.prototype.find` which isn't part of the standard Google typings.
|
|
2386
|
-
* @template T
|
|
2387
|
-
* @param {?} array Array in which to look for matches.
|
|
2388
|
-
* @param {?} predicate Function used to determine whether an item is a match.
|
|
2389
|
-
* @return {?}
|
|
2390
|
-
*/
|
|
2391
|
-
function findIndex(array, predicate) {
|
|
2392
|
-
for (var i = 0; i < array.length; i++) {
|
|
2393
|
-
if (predicate(array[i], i, array)) {
|
|
2394
|
-
return i;
|
|
2395
|
-
}
|
|
2396
|
-
}
|
|
2397
|
-
return -1;
|
|
2398
|
-
}
|
|
2399
|
-
/**
|
|
2400
|
-
* Checks whether some coordinates are within a `ClientRect`.
|
|
2401
|
-
* @param {?} clientRect ClientRect that is being checked.
|
|
2402
|
-
* @param {?} x Coordinates along the X axis.
|
|
2403
|
-
* @param {?} y Coordinates along the Y axis.
|
|
2404
|
-
* @return {?}
|
|
2405
|
-
*/
|
|
2406
|
-
function isInsideClientRect(clientRect, x, y) {
|
|
2407
|
-
var top = clientRect.top, bottom = clientRect.bottom, left = clientRect.left, right = clientRect.right;
|
|
2408
|
-
return y >= top && y <= bottom && x >= left && x <= right;
|
|
2409
|
-
}
|
|
2410
|
-
|
|
2411
|
-
/**
|
|
2412
|
-
* @fileoverview added by tsickle
|
|
2413
|
-
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2414
|
-
*/
|
|
2415
3395
|
|
|
2416
3396
|
/**
|
|
2417
3397
|
* @fileoverview added by tsickle
|
|
@@ -2453,5 +3433,5 @@ var DragDropModule = /** @class */ (function () {
|
|
|
2453
3433
|
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2454
3434
|
*/
|
|
2455
3435
|
|
|
2456
|
-
export {
|
|
3436
|
+
export { CDK_DROP_LIST, CDK_DROP_LIST_CONTAINER, moveItemInArray, transferArrayItem, copyArrayItem, DragDropModule, DragDropRegistry, CdkDropList, CdkDropListGroup, CDK_DRAG_CONFIG_FACTORY, CDK_DRAG_CONFIG, CdkDrag, CdkDragHandle, CdkDragPreview, CdkDragPlaceholder, CDK_DRAG_PARENT as ɵa };
|
|
2457
3437
|
//# sourceMappingURL=drag-drop.es5.js.map
|