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