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