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