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