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