@angular/cdk 8.0.0-beta.2 → 8.0.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/README.md +2 -2
- package/_overlay.scss +4 -4
- package/bundles/cdk-a11y.umd.js +227 -79
- 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 +20 -8
- 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 +5 -5
- 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-collections.umd.js +38 -15
- package/bundles/cdk-collections.umd.js.map +1 -1
- package/bundles/cdk-collections.umd.min.js +1 -1
- package/bundles/cdk-collections.umd.min.js.map +1 -1
- package/bundles/cdk-drag-drop.umd.js +571 -180
- package/bundles/cdk-drag-drop.umd.js.map +1 -1
- package/bundles/cdk-drag-drop.umd.min.js +2 -2
- package/bundles/cdk-drag-drop.umd.min.js.map +1 -1
- package/bundles/cdk-keycodes.umd.js +7 -3
- package/bundles/cdk-keycodes.umd.js.map +1 -1
- package/bundles/cdk-keycodes.umd.min.js.map +1 -1
- package/bundles/cdk-layout.umd.js +83 -30
- 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 +30 -11
- package/bundles/cdk-observers.umd.js.map +1 -1
- package/bundles/cdk-observers.umd.min.js +1 -1
- package/bundles/cdk-observers.umd.min.js.map +1 -1
- package/bundles/cdk-overlay.umd.js +229 -108
- 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 +17 -10
- package/bundles/cdk-platform.umd.js.map +1 -1
- package/bundles/cdk-platform.umd.min.js +1 -1
- package/bundles/cdk-platform.umd.min.js.map +1 -1
- package/bundles/cdk-portal.umd.js +32 -13
- 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 +184 -62
- 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 +30 -12
- package/bundles/cdk-stepper.umd.js.map +1 -1
- package/bundles/cdk-stepper.umd.min.js.map +1 -1
- package/bundles/cdk-table.umd.js +384 -74
- package/bundles/cdk-table.umd.js.map +1 -1
- package/bundles/cdk-table.umd.min.js +1 -1
- package/bundles/cdk-table.umd.min.js.map +1 -1
- package/bundles/cdk-text-field.umd.js +61 -21
- 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 +85 -29
- package/bundles/cdk-tree.umd.js.map +1 -1
- package/bundles/cdk-tree.umd.min.js.map +1 -1
- package/bundles/cdk.umd.js +2 -2
- 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/directives/drag.d.ts +11 -2
- package/drag-drop/typings/drag-events.d.ts +17 -0
- package/drag-drop/typings/drag-ref.d.ts +9 -5
- package/drag-drop/typings/drop-list-ref.d.ts +9 -3
- package/drag-drop/typings/index.metadata.json +1 -1
- package/esm2015/a11y.js +229 -81
- package/esm2015/a11y.js.map +1 -1
- package/esm2015/accordion.js +22 -10
- package/esm2015/accordion.js.map +1 -1
- package/esm2015/bidi.js +8 -8
- package/esm2015/cdk.js +4 -4
- package/esm2015/cdk.js.map +1 -1
- package/esm2015/coercion.js +7 -7
- package/esm2015/collections.js +41 -18
- package/esm2015/collections.js.map +1 -1
- package/esm2015/drag-drop.js +540 -181
- package/esm2015/drag-drop.js.map +1 -1
- package/esm2015/keycodes.js +9 -5
- package/esm2015/keycodes.js.map +1 -1
- package/esm2015/layout.js +89 -36
- package/esm2015/layout.js.map +1 -1
- package/esm2015/observers.js +33 -14
- package/esm2015/observers.js.map +1 -1
- package/esm2015/overlay.js +232 -110
- package/esm2015/overlay.js.map +1 -1
- package/esm2015/platform.js +20 -13
- package/esm2015/platform.js.map +1 -1
- package/esm2015/portal.js +34 -15
- package/esm2015/portal.js.map +1 -1
- package/esm2015/scrolling.js +180 -58
- package/esm2015/scrolling.js.map +1 -1
- package/esm2015/stepper.js +32 -14
- package/esm2015/stepper.js.map +1 -1
- package/esm2015/table.js +369 -69
- package/esm2015/table.js.map +1 -1
- package/esm2015/text-field.js +64 -24
- package/esm2015/text-field.js.map +1 -1
- package/esm2015/tree.js +86 -30
- package/esm2015/tree.js.map +1 -1
- package/esm5/a11y.es5.js +230 -82
- package/esm5/a11y.es5.js.map +1 -1
- package/esm5/accordion.es5.js +22 -10
- package/esm5/accordion.es5.js.map +1 -1
- package/esm5/bidi.es5.js +8 -8
- package/esm5/cdk.es5.js +4 -4
- package/esm5/cdk.es5.js.map +1 -1
- package/esm5/coercion.es5.js +7 -7
- package/esm5/collections.es5.js +42 -19
- package/esm5/collections.es5.js.map +1 -1
- package/esm5/drag-drop.es5.js +574 -183
- package/esm5/drag-drop.es5.js.map +1 -1
- package/esm5/keycodes.es5.js +9 -5
- package/esm5/keycodes.es5.js.map +1 -1
- package/esm5/layout.es5.js +86 -33
- package/esm5/layout.es5.js.map +1 -1
- package/esm5/observers.es5.js +33 -14
- package/esm5/observers.es5.js.map +1 -1
- package/esm5/overlay.es5.js +232 -111
- package/esm5/overlay.es5.js.map +1 -1
- package/esm5/platform.es5.js +20 -13
- package/esm5/platform.es5.js.map +1 -1
- package/esm5/portal.es5.js +34 -15
- package/esm5/portal.es5.js.map +1 -1
- package/esm5/scrolling.es5.js +187 -65
- package/esm5/scrolling.es5.js.map +1 -1
- package/esm5/stepper.es5.js +32 -14
- package/esm5/stepper.es5.js.map +1 -1
- package/esm5/table.es5.js +386 -72
- package/esm5/table.es5.js.map +1 -1
- package/esm5/text-field.es5.js +64 -24
- package/esm5/text-field.es5.js.map +1 -1
- package/esm5/tree.es5.js +87 -31
- package/esm5/tree.es5.js.map +1 -1
- package/layout/typings/breakpoints-observer.d.ts +3 -3
- package/layout/typings/index.metadata.json +1 -1
- package/layout/typings/media-matcher.d.ts +2 -2
- package/overlay/typings/index.metadata.json +1 -1
- package/overlay/typings/position/flexible-connected-position-strategy.d.ts +1 -3
- package/package.json +8 -8
- package/portal/typings/portal.d.ts +2 -2
- package/schematics/ng-update/data/attribute-selectors.js +1 -1
- package/schematics/ng-update/data/attribute-selectors.js.map +1 -1
- package/schematics/ng-update/data/class-names.js +3 -3
- package/schematics/ng-update/data/class-names.js.map +1 -1
- package/schematics/ng-update/data/constructor-checks.js +1 -1
- package/schematics/ng-update/data/constructor-checks.js.map +1 -1
- package/schematics/ng-update/data/input-names.js +1 -1
- package/schematics/ng-update/data/input-names.js.map +1 -1
- package/schematics/ng-update/data/method-call-checks.js +1 -1
- package/schematics/ng-update/data/method-call-checks.js.map +1 -1
- package/schematics/ng-update/data/property-names.js +4 -4
- package/schematics/ng-update/data/property-names.js.map +1 -1
- package/schematics/ng-update/upgrade-rules/signature-check/constructorSignatureCheckRule.js +1 -1
- package/schematics/ng-update/upgrade-rules/signature-check/constructorSignatureCheckRule.js.map +1 -1
- package/schematics/tsconfig.tsbuildinfo +5811 -0
- package/schematics/utils/ast.d.ts +1 -1
- package/schematics/utils/build-component.js +1 -1
- package/schematics/utils/build-component.js.map +1 -1
- package/schematics/utils/get-project.d.ts +1 -1
- package/schematics/utils/project-main-file.d.ts +1 -1
- package/schematics/utils/project-style-file.d.ts +1 -1
- package/schematics/utils/project-targets.d.ts +1 -1
- package/schematics/utils/schematic-options.d.ts +1 -1
- package/table/typings/cell.d.ts +3 -2
- package/table/typings/index.metadata.json +1 -1
- package/table/typings/public-api.d.ts +1 -0
- package/table/typings/row.d.ts +5 -4
- package/table/typings/sticky-styler.d.ts +5 -5
- package/table/typings/table-errors.d.ts +10 -0
- package/table/typings/text-column.d.ts +80 -0
- package/typings/drag-drop/directives/drag.d.ts +11 -2
- package/typings/drag-drop/drag-events.d.ts +17 -0
- package/typings/drag-drop/drag-ref.d.ts +9 -5
- package/typings/drag-drop/drop-list-ref.d.ts +9 -3
- package/typings/drag-drop/index.metadata.json +1 -1
- package/typings/esm5/drag-drop/directives/drag.d.ts +11 -2
- package/typings/esm5/drag-drop/drag-events.d.ts +17 -0
- package/typings/esm5/drag-drop/drag-ref.d.ts +9 -5
- package/typings/esm5/drag-drop/drop-list-ref.d.ts +9 -3
- package/typings/esm5/drag-drop/index.metadata.json +1 -1
- package/typings/esm5/index.metadata.json +1 -1
- package/typings/esm5/layout/breakpoints-observer.d.ts +3 -3
- package/typings/esm5/layout/index.metadata.json +1 -1
- package/typings/esm5/layout/media-matcher.d.ts +2 -2
- package/typings/esm5/overlay/index.metadata.json +1 -1
- package/typings/esm5/overlay/position/flexible-connected-position-strategy.d.ts +1 -3
- package/typings/esm5/portal/portal.d.ts +2 -2
- package/typings/esm5/table/cell.d.ts +3 -2
- package/typings/esm5/table/index.metadata.json +1 -1
- package/typings/esm5/table/public-api.d.ts +1 -0
- package/typings/esm5/table/row.d.ts +5 -4
- package/typings/esm5/table/sticky-styler.d.ts +5 -5
- package/typings/esm5/table/table-errors.d.ts +10 -0
- package/typings/esm5/table/text-column.d.ts +80 -0
- package/typings/index.metadata.json +1 -1
- package/typings/layout/breakpoints-observer.d.ts +3 -3
- package/typings/layout/index.metadata.json +1 -1
- package/typings/layout/media-matcher.d.ts +2 -2
- package/typings/overlay/index.metadata.json +1 -1
- package/typings/overlay/position/flexible-connected-position-strategy.d.ts +1 -3
- package/typings/portal/portal.d.ts +2 -2
- package/typings/schematics/utils/ast.d.ts +1 -1
- package/typings/schematics/utils/get-project.d.ts +1 -1
- package/typings/schematics/utils/project-main-file.d.ts +1 -1
- package/typings/schematics/utils/project-style-file.d.ts +1 -1
- package/typings/schematics/utils/project-targets.d.ts +1 -1
- package/typings/schematics/utils/schematic-options.d.ts +1 -1
- package/typings/table/cell.d.ts +3 -2
- package/typings/table/index.metadata.json +1 -1
- package/typings/table/public-api.d.ts +1 -0
- package/typings/table/row.d.ts +5 -4
- package/typings/table/sticky-styler.d.ts +5 -5
- package/typings/table/table-errors.d.ts +10 -0
- package/typings/table/text-column.d.ts +80 -0
package/esm2015/drag-drop.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { normalizePassiveListenerOptions } from '@angular/cdk/platform';
|
|
9
9
|
import { coerceBooleanProperty, coerceElement, coerceNumberProperty, coerceArray } from '@angular/cdk/coercion';
|
|
10
10
|
import { Subscription, Subject, Observable, merge } from 'rxjs';
|
|
11
|
-
import { ElementRef, Injectable, NgZone, Inject, InjectionToken, NgModule, ContentChildren, EventEmitter, forwardRef, Input, Output, Optional, Directive, ChangeDetectorRef, SkipSelf, ContentChild, ViewContainerRef, TemplateRef,
|
|
11
|
+
import { ElementRef, Injectable, NgZone, Inject, InjectionToken, NgModule, ContentChildren, EventEmitter, forwardRef, Input, Output, Optional, Directive, ChangeDetectorRef, SkipSelf, ContentChild, ViewContainerRef, isDevMode, TemplateRef, ɵɵdefineInjectable, ɵɵinject } from '@angular/core';
|
|
12
12
|
import { DOCUMENT } from '@angular/common';
|
|
13
13
|
import { ViewportRuler } from '@angular/cdk/scrolling';
|
|
14
14
|
import { Directionality } from '@angular/cdk/bidi';
|
|
@@ -16,7 +16,7 @@ import { startWith, take, map, takeUntil, switchMap, tap } from 'rxjs/operators'
|
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* @fileoverview added by tsickle
|
|
19
|
-
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
19
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
20
20
|
*/
|
|
21
21
|
/**
|
|
22
22
|
* Shallow-extends a stylesheet object with another stylesheet object.
|
|
@@ -56,7 +56,7 @@ function toggleNativeDragInteractions(element, enable) {
|
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
58
|
* @fileoverview added by tsickle
|
|
59
|
-
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
59
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
60
60
|
*/
|
|
61
61
|
|
|
62
62
|
/**
|
|
@@ -81,7 +81,11 @@ function getTransformTransitionDurationInMs(element) {
|
|
|
81
81
|
/** @type {?} */
|
|
82
82
|
const transitionedProperties = parseCssPropertyValue(computedStyle, 'transition-property');
|
|
83
83
|
/** @type {?} */
|
|
84
|
-
const property = transitionedProperties.find(
|
|
84
|
+
const property = transitionedProperties.find((/**
|
|
85
|
+
* @param {?} prop
|
|
86
|
+
* @return {?}
|
|
87
|
+
*/
|
|
88
|
+
prop => prop === 'transform' || prop === 'all'));
|
|
85
89
|
// If there's no transition for `all` or `transform`, we shouldn't do anything.
|
|
86
90
|
if (!property) {
|
|
87
91
|
return 0;
|
|
@@ -106,12 +110,16 @@ function getTransformTransitionDurationInMs(element) {
|
|
|
106
110
|
function parseCssPropertyValue(computedStyle, name) {
|
|
107
111
|
/** @type {?} */
|
|
108
112
|
const value = computedStyle.getPropertyValue(name);
|
|
109
|
-
return value.split(',').map(
|
|
113
|
+
return value.split(',').map((/**
|
|
114
|
+
* @param {?} part
|
|
115
|
+
* @return {?}
|
|
116
|
+
*/
|
|
117
|
+
part => part.trim()));
|
|
110
118
|
}
|
|
111
119
|
|
|
112
120
|
/**
|
|
113
121
|
* @fileoverview added by tsickle
|
|
114
|
-
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
122
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
115
123
|
*/
|
|
116
124
|
/**
|
|
117
125
|
* Options that can be used to bind a passive event listener.
|
|
@@ -166,11 +174,6 @@ class DragRef {
|
|
|
166
174
|
* Emits when the item is being moved.
|
|
167
175
|
*/
|
|
168
176
|
this._moveEvents = new Subject();
|
|
169
|
-
/**
|
|
170
|
-
* Amount of subscriptions to the move event. Used to avoid
|
|
171
|
-
* hitting the zone if the consumer didn't subscribe to it.
|
|
172
|
-
*/
|
|
173
|
-
this._moveEventSubscriptions = 0;
|
|
174
177
|
/**
|
|
175
178
|
* Subscription to pointer movement events.
|
|
176
179
|
*/
|
|
@@ -237,28 +240,28 @@ class DragRef {
|
|
|
237
240
|
* Emits as the user is dragging the item. Use with caution,
|
|
238
241
|
* because this event will fire for every pixel that the user has dragged.
|
|
239
242
|
*/
|
|
240
|
-
this.moved =
|
|
241
|
-
/** @type {?} */
|
|
242
|
-
const subscription = this._moveEvents.subscribe(observer);
|
|
243
|
-
this._moveEventSubscriptions++;
|
|
244
|
-
return () => {
|
|
245
|
-
subscription.unsubscribe();
|
|
246
|
-
this._moveEventSubscriptions--;
|
|
247
|
-
};
|
|
248
|
-
});
|
|
243
|
+
this.moved = this._moveEvents.asObservable();
|
|
249
244
|
/**
|
|
250
245
|
* Handler for the `mousedown`/`touchstart` events.
|
|
251
246
|
*/
|
|
252
|
-
this._pointerDown = (
|
|
247
|
+
this._pointerDown = (/**
|
|
248
|
+
* @param {?} event
|
|
249
|
+
* @return {?}
|
|
250
|
+
*/
|
|
251
|
+
(event) => {
|
|
253
252
|
this.beforeStarted.next();
|
|
254
253
|
// Delegate the event based on whether it started from a handle or the element itself.
|
|
255
254
|
if (this._handles.length) {
|
|
256
255
|
/** @type {?} */
|
|
257
|
-
const targetHandle = this._handles.find(
|
|
256
|
+
const targetHandle = this._handles.find((/**
|
|
257
|
+
* @param {?} handle
|
|
258
|
+
* @return {?}
|
|
259
|
+
*/
|
|
260
|
+
handle => {
|
|
258
261
|
/** @type {?} */
|
|
259
262
|
const target = event.target;
|
|
260
263
|
return !!target && (target === handle || handle.contains((/** @type {?} */ (target))));
|
|
261
|
-
});
|
|
264
|
+
}));
|
|
262
265
|
if (targetHandle && !this._disabledHandles.has(targetHandle) && !this.disabled) {
|
|
263
266
|
this._initializeDragSequence(targetHandle, event);
|
|
264
267
|
}
|
|
@@ -266,11 +269,15 @@ class DragRef {
|
|
|
266
269
|
else if (!this.disabled) {
|
|
267
270
|
this._initializeDragSequence(this._rootElement, event);
|
|
268
271
|
}
|
|
269
|
-
};
|
|
272
|
+
});
|
|
270
273
|
/**
|
|
271
274
|
* Handler that is invoked when the user moves their pointer after they've initiated a drag.
|
|
272
275
|
*/
|
|
273
|
-
this._pointerMove = (
|
|
276
|
+
this._pointerMove = (/**
|
|
277
|
+
* @param {?} event
|
|
278
|
+
* @return {?}
|
|
279
|
+
*/
|
|
280
|
+
(event) => {
|
|
274
281
|
if (!this._hasStartedDragging) {
|
|
275
282
|
/** @type {?} */
|
|
276
283
|
const pointerPosition = this._getPointerPositionOnPage(event);
|
|
@@ -286,7 +293,10 @@ class DragRef {
|
|
|
286
293
|
// per pixel of movement (e.g. if the user moves their pointer quickly).
|
|
287
294
|
if (isOverThreshold && (Date.now() >= this._dragStartTime + (this.dragStartDelay || 0))) {
|
|
288
295
|
this._hasStartedDragging = true;
|
|
289
|
-
this._ngZone.run((
|
|
296
|
+
this._ngZone.run((/**
|
|
297
|
+
* @return {?}
|
|
298
|
+
*/
|
|
299
|
+
() => this._startDragSequence(event)));
|
|
290
300
|
}
|
|
291
301
|
return;
|
|
292
302
|
}
|
|
@@ -324,21 +334,29 @@ class DragRef {
|
|
|
324
334
|
// Since this event gets fired for every pixel while dragging, we only
|
|
325
335
|
// want to fire it if the consumer opted into it. Also we have to
|
|
326
336
|
// re-enter the zone because we run all of the events on the outside.
|
|
327
|
-
if (this.
|
|
328
|
-
this._ngZone.run((
|
|
337
|
+
if (this._moveEvents.observers.length) {
|
|
338
|
+
this._ngZone.run((/**
|
|
339
|
+
* @return {?}
|
|
340
|
+
*/
|
|
341
|
+
() => {
|
|
329
342
|
this._moveEvents.next({
|
|
330
343
|
source: this,
|
|
331
344
|
pointerPosition: constrainedPointerPosition,
|
|
332
345
|
event,
|
|
346
|
+
distance: this._getDragDistance(constrainedPointerPosition),
|
|
333
347
|
delta: this._pointerDirectionDelta
|
|
334
348
|
});
|
|
335
|
-
});
|
|
349
|
+
}));
|
|
336
350
|
}
|
|
337
|
-
};
|
|
351
|
+
});
|
|
338
352
|
/**
|
|
339
353
|
* Handler that is invoked when the user lifts their pointer up, after initiating a drag.
|
|
340
354
|
*/
|
|
341
|
-
this._pointerUp = (
|
|
355
|
+
this._pointerUp = (/**
|
|
356
|
+
* @param {?} event
|
|
357
|
+
* @return {?}
|
|
358
|
+
*/
|
|
359
|
+
(event) => {
|
|
342
360
|
// Note that here we use `isDragging` from the service, rather than from `this`.
|
|
343
361
|
// The difference is that the one from the service reflects whether a dragging sequence
|
|
344
362
|
// has been initiated, whereas the one on `this` includes whether the user has passed
|
|
@@ -361,15 +379,26 @@ class DragRef {
|
|
|
361
379
|
// to the new passive transform.
|
|
362
380
|
this._passiveTransform.x = this._activeTransform.x;
|
|
363
381
|
this._passiveTransform.y = this._activeTransform.y;
|
|
364
|
-
this._ngZone.run((
|
|
382
|
+
this._ngZone.run((/**
|
|
383
|
+
* @return {?}
|
|
384
|
+
*/
|
|
385
|
+
() => {
|
|
386
|
+
this.ended.next({
|
|
387
|
+
source: this,
|
|
388
|
+
distance: this._getDragDistance(this._getPointerPositionOnPage(event))
|
|
389
|
+
});
|
|
390
|
+
}));
|
|
365
391
|
this._dragDropRegistry.stopDragging(this);
|
|
366
392
|
return;
|
|
367
393
|
}
|
|
368
|
-
this._animatePreviewToPlaceholder().then((
|
|
394
|
+
this._animatePreviewToPlaceholder().then((/**
|
|
395
|
+
* @return {?}
|
|
396
|
+
*/
|
|
397
|
+
() => {
|
|
369
398
|
this._cleanupDragArtifacts(event);
|
|
370
399
|
this._dragDropRegistry.stopDragging(this);
|
|
371
|
-
});
|
|
372
|
-
};
|
|
400
|
+
}));
|
|
401
|
+
});
|
|
373
402
|
this.withRootElement(element);
|
|
374
403
|
_dragDropRegistry.registerDragItem(this);
|
|
375
404
|
}
|
|
@@ -415,8 +444,16 @@ class DragRef {
|
|
|
415
444
|
* @return {THIS}
|
|
416
445
|
*/
|
|
417
446
|
withHandles(handles) {
|
|
418
|
-
(/** @type {?} */ (this))._handles = handles.map(
|
|
419
|
-
|
|
447
|
+
(/** @type {?} */ (this))._handles = handles.map((/**
|
|
448
|
+
* @param {?} handle
|
|
449
|
+
* @return {?}
|
|
450
|
+
*/
|
|
451
|
+
handle => coerceElement(handle)));
|
|
452
|
+
(/** @type {?} */ (this))._handles.forEach((/**
|
|
453
|
+
* @param {?} handle
|
|
454
|
+
* @return {?}
|
|
455
|
+
*/
|
|
456
|
+
handle => toggleNativeDragInteractions(handle, false)));
|
|
420
457
|
(/** @type {?} */ (this))._toggleNativeDragInteractions();
|
|
421
458
|
return (/** @type {?} */ (this));
|
|
422
459
|
}
|
|
@@ -732,32 +769,39 @@ class DragRef {
|
|
|
732
769
|
(/** @type {?} */ (this._nextSibling.parentNode)).insertBefore(this._rootElement, this._nextSibling);
|
|
733
770
|
}
|
|
734
771
|
else {
|
|
735
|
-
this._initialContainer.element.appendChild(this._rootElement);
|
|
772
|
+
coerceElement(this._initialContainer.element).appendChild(this._rootElement);
|
|
736
773
|
}
|
|
737
774
|
this._destroyPreview();
|
|
738
775
|
this._destroyPlaceholder();
|
|
739
776
|
this._boundaryRect = this._previewRect = undefined;
|
|
740
777
|
// Re-enter the NgZone since we bound `document` events on the outside.
|
|
741
|
-
this._ngZone.run((
|
|
778
|
+
this._ngZone.run((/**
|
|
779
|
+
* @return {?}
|
|
780
|
+
*/
|
|
781
|
+
() => {
|
|
742
782
|
/** @type {?} */
|
|
743
783
|
const container = (/** @type {?} */ (this._dropContainer));
|
|
744
784
|
/** @type {?} */
|
|
745
785
|
const currentIndex = container.getItemIndex(this);
|
|
746
|
-
const { x, y } = this._getPointerPositionOnPage(event);
|
|
747
786
|
/** @type {?} */
|
|
748
|
-
const
|
|
749
|
-
|
|
787
|
+
const pointerPosition = this._getPointerPositionOnPage(event);
|
|
788
|
+
/** @type {?} */
|
|
789
|
+
const distance = this._getDragDistance(this._getPointerPositionOnPage(event));
|
|
790
|
+
/** @type {?} */
|
|
791
|
+
const isPointerOverContainer = container._isOverContainer(pointerPosition.x, pointerPosition.y);
|
|
792
|
+
this.ended.next({ source: this, distance });
|
|
750
793
|
this.dropped.next({
|
|
751
794
|
item: this,
|
|
752
795
|
currentIndex,
|
|
753
796
|
previousIndex: this._initialContainer.getItemIndex(this),
|
|
754
797
|
container: container,
|
|
755
798
|
previousContainer: this._initialContainer,
|
|
756
|
-
isPointerOverContainer
|
|
799
|
+
isPointerOverContainer,
|
|
800
|
+
distance
|
|
757
801
|
});
|
|
758
|
-
container.drop(this, currentIndex, this._initialContainer, isPointerOverContainer);
|
|
802
|
+
container.drop(this, currentIndex, this._initialContainer, isPointerOverContainer, distance);
|
|
759
803
|
this._dropContainer = this._initialContainer;
|
|
760
|
-
});
|
|
804
|
+
}));
|
|
761
805
|
}
|
|
762
806
|
/**
|
|
763
807
|
* Updates the item's position in its drop container, or moves it
|
|
@@ -769,8 +813,7 @@ class DragRef {
|
|
|
769
813
|
_updateActiveDropContainer({ x, y }) {
|
|
770
814
|
// Drop container that draggable has been moved into.
|
|
771
815
|
/** @type {?} */
|
|
772
|
-
let newContainer =
|
|
773
|
-
this._initialContainer._getSiblingContainerFromPosition(this, x, y);
|
|
816
|
+
let newContainer = this._initialContainer._getSiblingContainerFromPosition(this, x, y);
|
|
774
817
|
// If we couldn't find a new container to move the item into, and the item has left it's
|
|
775
818
|
// initial container, check whether the it's over the initial container. This handles the
|
|
776
819
|
// case where two containers are connected one way and the user tries to undo dragging an
|
|
@@ -780,15 +823,22 @@ class DragRef {
|
|
|
780
823
|
newContainer = this._initialContainer;
|
|
781
824
|
}
|
|
782
825
|
if (newContainer && newContainer !== this._dropContainer) {
|
|
783
|
-
this._ngZone.run((
|
|
826
|
+
this._ngZone.run((/**
|
|
827
|
+
* @return {?}
|
|
828
|
+
*/
|
|
829
|
+
() => {
|
|
784
830
|
// Notify the old container that the item has left.
|
|
785
831
|
this.exited.next({ item: this, container: (/** @type {?} */ (this._dropContainer)) });
|
|
786
832
|
(/** @type {?} */ (this._dropContainer)).exit(this);
|
|
787
833
|
// Notify the new container that the item has entered.
|
|
788
|
-
this.entered.next({ item: this, container: (/** @type {?} */ (newContainer)) });
|
|
789
834
|
this._dropContainer = (/** @type {?} */ (newContainer));
|
|
790
835
|
this._dropContainer.enter(this, x, y);
|
|
791
|
-
|
|
836
|
+
this.entered.next({
|
|
837
|
+
item: this,
|
|
838
|
+
container: (/** @type {?} */ (newContainer)),
|
|
839
|
+
currentIndex: (/** @type {?} */ (newContainer)).getItemIndex(this)
|
|
840
|
+
});
|
|
841
|
+
}));
|
|
792
842
|
}
|
|
793
843
|
(/** @type {?} */ (this._dropContainer))._sortItem(this, x, y, this._pointerDirectionDelta);
|
|
794
844
|
this._preview.style.transform =
|
|
@@ -864,24 +914,35 @@ class DragRef {
|
|
|
864
914
|
if (duration === 0) {
|
|
865
915
|
return Promise.resolve();
|
|
866
916
|
}
|
|
867
|
-
return this._ngZone.runOutsideAngular((
|
|
868
|
-
|
|
917
|
+
return this._ngZone.runOutsideAngular((/**
|
|
918
|
+
* @return {?}
|
|
919
|
+
*/
|
|
920
|
+
() => {
|
|
921
|
+
return new Promise((/**
|
|
922
|
+
* @param {?} resolve
|
|
923
|
+
* @return {?}
|
|
924
|
+
*/
|
|
925
|
+
resolve => {
|
|
869
926
|
/** @type {?} */
|
|
870
|
-
const handler = (/** @type {?} */ (((
|
|
927
|
+
const handler = (/** @type {?} */ (((/**
|
|
928
|
+
* @param {?} event
|
|
929
|
+
* @return {?}
|
|
930
|
+
*/
|
|
931
|
+
(event) => {
|
|
871
932
|
if (!event || (event.target === this._preview && event.propertyName === 'transform')) {
|
|
872
933
|
this._preview.removeEventListener('transitionend', handler);
|
|
873
934
|
resolve();
|
|
874
935
|
clearTimeout(timeout);
|
|
875
936
|
}
|
|
876
|
-
})));
|
|
937
|
+
}))));
|
|
877
938
|
// If a transition is short enough, the browser might not fire the `transitionend` event.
|
|
878
939
|
// Since we know how long it's supposed to take, add a timeout with a 50% buffer that'll
|
|
879
940
|
// fire if the transition hasn't completed when it was supposed to.
|
|
880
941
|
/** @type {?} */
|
|
881
942
|
const timeout = setTimeout((/** @type {?} */ (handler)), duration * 1.5);
|
|
882
943
|
this._preview.addEventListener('transitionend', handler);
|
|
883
|
-
});
|
|
884
|
-
});
|
|
944
|
+
}));
|
|
945
|
+
}));
|
|
885
946
|
}
|
|
886
947
|
/**
|
|
887
948
|
* Creates an element that will be shown instead of the current element while dragging.
|
|
@@ -1061,6 +1122,20 @@ class DragRef {
|
|
|
1061
1122
|
this._rootElement.style.transform = this._initialTransform ?
|
|
1062
1123
|
transform + ' ' + this._initialTransform : transform;
|
|
1063
1124
|
}
|
|
1125
|
+
/**
|
|
1126
|
+
* Gets the distance that the user has dragged during the current drag sequence.
|
|
1127
|
+
* @private
|
|
1128
|
+
* @param {?} currentPosition Current position of the user's pointer.
|
|
1129
|
+
* @return {?}
|
|
1130
|
+
*/
|
|
1131
|
+
_getDragDistance(currentPosition) {
|
|
1132
|
+
/** @type {?} */
|
|
1133
|
+
const pickupPosition = this._pickupPositionOnPage;
|
|
1134
|
+
if (pickupPosition) {
|
|
1135
|
+
return { x: currentPosition.x - pickupPosition.x, y: currentPosition.y - pickupPosition.y };
|
|
1136
|
+
}
|
|
1137
|
+
return { x: 0, y: 0 };
|
|
1138
|
+
}
|
|
1064
1139
|
}
|
|
1065
1140
|
/**
|
|
1066
1141
|
* Gets a 3d `transform` that can be applied to an element.
|
|
@@ -1083,11 +1158,26 @@ function deepCloneNode(node) {
|
|
|
1083
1158
|
const clone = (/** @type {?} */ (node.cloneNode(true)));
|
|
1084
1159
|
/** @type {?} */
|
|
1085
1160
|
const descendantsWithId = clone.querySelectorAll('[id]');
|
|
1161
|
+
/** @type {?} */
|
|
1162
|
+
const descendantCanvases = node.querySelectorAll('canvas');
|
|
1086
1163
|
// Remove the `id` to avoid having multiple elements with the same id on the page.
|
|
1087
1164
|
clone.removeAttribute('id');
|
|
1088
1165
|
for (let i = 0; i < descendantsWithId.length; i++) {
|
|
1089
1166
|
descendantsWithId[i].removeAttribute('id');
|
|
1090
1167
|
}
|
|
1168
|
+
// `cloneNode` won't transfer the content of `canvas` elements so we have to do it ourselves.
|
|
1169
|
+
// We match up the cloned canvas to their sources using their index in the DOM.
|
|
1170
|
+
if (descendantCanvases.length) {
|
|
1171
|
+
/** @type {?} */
|
|
1172
|
+
const cloneCanvases = clone.querySelectorAll('canvas');
|
|
1173
|
+
for (let i = 0; i < descendantCanvases.length; i++) {
|
|
1174
|
+
/** @type {?} */
|
|
1175
|
+
const correspondingCloneContext = cloneCanvases[i].getContext('2d');
|
|
1176
|
+
if (correspondingCloneContext) {
|
|
1177
|
+
correspondingCloneContext.drawImage(descendantCanvases[i], 0, 0);
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1091
1181
|
return clone;
|
|
1092
1182
|
}
|
|
1093
1183
|
/**
|
|
@@ -1136,7 +1226,7 @@ function getPreviewInsertionPoint(documentRef) {
|
|
|
1136
1226
|
|
|
1137
1227
|
/**
|
|
1138
1228
|
* @fileoverview added by tsickle
|
|
1139
|
-
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1229
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1140
1230
|
*/
|
|
1141
1231
|
|
|
1142
1232
|
/**
|
|
@@ -1212,7 +1302,7 @@ function clamp$1(value, max) {
|
|
|
1212
1302
|
|
|
1213
1303
|
/**
|
|
1214
1304
|
* @fileoverview added by tsickle
|
|
1215
|
-
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1305
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1216
1306
|
*/
|
|
1217
1307
|
/**
|
|
1218
1308
|
* Counter used to generate unique ids for drop refs.
|
|
@@ -1256,7 +1346,10 @@ class DropListRef {
|
|
|
1256
1346
|
* Function that is used to determine whether an item
|
|
1257
1347
|
* is allowed to be moved into a drop container.
|
|
1258
1348
|
*/
|
|
1259
|
-
this.enterPredicate = (
|
|
1349
|
+
this.enterPredicate = (/**
|
|
1350
|
+
* @return {?}
|
|
1351
|
+
*/
|
|
1352
|
+
() => true);
|
|
1260
1353
|
/**
|
|
1261
1354
|
* Emits right before dragging has started.
|
|
1262
1355
|
*/
|
|
@@ -1338,10 +1431,12 @@ class DropListRef {
|
|
|
1338
1431
|
start() {
|
|
1339
1432
|
this.beforeStarted.next();
|
|
1340
1433
|
this._isDragging = true;
|
|
1341
|
-
this.
|
|
1342
|
-
this.
|
|
1343
|
-
|
|
1344
|
-
|
|
1434
|
+
this._cacheItems();
|
|
1435
|
+
this._siblings.forEach((/**
|
|
1436
|
+
* @param {?} sibling
|
|
1437
|
+
* @return {?}
|
|
1438
|
+
*/
|
|
1439
|
+
sibling => sibling._startReceiving(this)));
|
|
1345
1440
|
}
|
|
1346
1441
|
/**
|
|
1347
1442
|
* Emits an event to indicate that the user moved an item into the container.
|
|
@@ -1351,7 +1446,6 @@ class DropListRef {
|
|
|
1351
1446
|
* @return {?}
|
|
1352
1447
|
*/
|
|
1353
1448
|
enter(item, pointerX, pointerY) {
|
|
1354
|
-
this.entered.next({ item, container: this });
|
|
1355
1449
|
this.start();
|
|
1356
1450
|
// If sorting is disabled, we want the item to return to its starting
|
|
1357
1451
|
// position if the user is returning it to its initial container.
|
|
@@ -1390,7 +1484,7 @@ class DropListRef {
|
|
|
1390
1484
|
activeDraggables.splice(newIndex, 0, item);
|
|
1391
1485
|
}
|
|
1392
1486
|
else {
|
|
1393
|
-
this.element.appendChild(placeholder);
|
|
1487
|
+
coerceElement(this.element).appendChild(placeholder);
|
|
1394
1488
|
activeDraggables.push(item);
|
|
1395
1489
|
}
|
|
1396
1490
|
// The transform needs to be cleared so it doesn't throw off the measurements.
|
|
@@ -1398,6 +1492,7 @@ class DropListRef {
|
|
|
1398
1492
|
// Note that the positions were already cached when we called `start` above,
|
|
1399
1493
|
// but we need to refresh them since the amount of items has changed.
|
|
1400
1494
|
this._cacheItemPositions();
|
|
1495
|
+
this.entered.next({ item, container: this, currentIndex: this.getItemIndex(item) });
|
|
1401
1496
|
}
|
|
1402
1497
|
/**
|
|
1403
1498
|
* Removes an item from the container after it was dragged into another container by the user.
|
|
@@ -1410,14 +1505,16 @@ class DropListRef {
|
|
|
1410
1505
|
}
|
|
1411
1506
|
/**
|
|
1412
1507
|
* Drops an item into this container.
|
|
1508
|
+
* \@breaking-change 9.0.0 `distance` parameter to become required.
|
|
1413
1509
|
* @param {?} item Item being dropped into the container.
|
|
1414
1510
|
* @param {?} currentIndex Index at which the item should be inserted.
|
|
1415
1511
|
* @param {?} previousContainer Container from which the item got dragged in.
|
|
1416
1512
|
* @param {?} isPointerOverContainer Whether the user's pointer was over the
|
|
1417
1513
|
* container when the item was dropped.
|
|
1514
|
+
* @param {?=} distance Distance the user has dragged since the start of the dragging sequence.
|
|
1418
1515
|
* @return {?}
|
|
1419
1516
|
*/
|
|
1420
|
-
drop(item, currentIndex, previousContainer, isPointerOverContainer) {
|
|
1517
|
+
drop(item, currentIndex, previousContainer, isPointerOverContainer, distance = { x: 0, y: 0 }) {
|
|
1421
1518
|
this._reset();
|
|
1422
1519
|
this.dropped.next({
|
|
1423
1520
|
item,
|
|
@@ -1425,7 +1522,8 @@ class DropListRef {
|
|
|
1425
1522
|
previousIndex: previousContainer.getItemIndex(item),
|
|
1426
1523
|
container: this,
|
|
1427
1524
|
previousContainer,
|
|
1428
|
-
isPointerOverContainer
|
|
1525
|
+
isPointerOverContainer,
|
|
1526
|
+
distance
|
|
1429
1527
|
});
|
|
1430
1528
|
}
|
|
1431
1529
|
/**
|
|
@@ -1437,7 +1535,14 @@ class DropListRef {
|
|
|
1437
1535
|
*/
|
|
1438
1536
|
withItems(items) {
|
|
1439
1537
|
(/** @type {?} */ (this))._draggables = items;
|
|
1440
|
-
items.forEach(
|
|
1538
|
+
items.forEach((/**
|
|
1539
|
+
* @param {?} item
|
|
1540
|
+
* @return {?}
|
|
1541
|
+
*/
|
|
1542
|
+
item => item._withDropContainer((/** @type {?} */ (this)))));
|
|
1543
|
+
if ((/** @type {?} */ (this)).isDragging()) {
|
|
1544
|
+
(/** @type {?} */ (this))._cacheItems();
|
|
1545
|
+
}
|
|
1441
1546
|
return (/** @type {?} */ (this));
|
|
1442
1547
|
}
|
|
1443
1548
|
/**
|
|
@@ -1489,7 +1594,11 @@ class DropListRef {
|
|
|
1489
1594
|
/** @type {?} */
|
|
1490
1595
|
const items = this._orientation === 'horizontal' && this._direction === 'rtl' ?
|
|
1491
1596
|
this._itemPositions.slice().reverse() : this._itemPositions;
|
|
1492
|
-
return findIndex(items,
|
|
1597
|
+
return findIndex(items, (/**
|
|
1598
|
+
* @param {?} currentItem
|
|
1599
|
+
* @return {?}
|
|
1600
|
+
*/
|
|
1601
|
+
currentItem => currentItem.drag === item));
|
|
1493
1602
|
}
|
|
1494
1603
|
/**
|
|
1495
1604
|
* Whether the list is able to receive the item that
|
|
@@ -1522,7 +1631,11 @@ class DropListRef {
|
|
|
1522
1631
|
/** @type {?} */
|
|
1523
1632
|
const isHorizontal = this._orientation === 'horizontal';
|
|
1524
1633
|
/** @type {?} */
|
|
1525
|
-
const currentIndex = findIndex(siblings,
|
|
1634
|
+
const currentIndex = findIndex(siblings, (/**
|
|
1635
|
+
* @param {?} currentItem
|
|
1636
|
+
* @return {?}
|
|
1637
|
+
*/
|
|
1638
|
+
currentItem => currentItem.drag === item));
|
|
1526
1639
|
/** @type {?} */
|
|
1527
1640
|
const siblingAtNewPosition = siblings[newIndex];
|
|
1528
1641
|
/** @type {?} */
|
|
@@ -1551,7 +1664,12 @@ class DropListRef {
|
|
|
1551
1664
|
container: this,
|
|
1552
1665
|
item
|
|
1553
1666
|
});
|
|
1554
|
-
siblings.forEach((
|
|
1667
|
+
siblings.forEach((/**
|
|
1668
|
+
* @param {?} sibling
|
|
1669
|
+
* @param {?} index
|
|
1670
|
+
* @return {?}
|
|
1671
|
+
*/
|
|
1672
|
+
(sibling, index) => {
|
|
1555
1673
|
// Don't do anything if the position hasn't changed.
|
|
1556
1674
|
if (oldOrder[index] === sibling) {
|
|
1557
1675
|
return;
|
|
@@ -1579,7 +1697,7 @@ class DropListRef {
|
|
|
1579
1697
|
elementToOffset.style.transform = `translate3d(0, ${Math.round(sibling.offset)}px, 0)`;
|
|
1580
1698
|
adjustClientRect(sibling.clientRect, offset, 0);
|
|
1581
1699
|
}
|
|
1582
|
-
});
|
|
1700
|
+
}));
|
|
1583
1701
|
}
|
|
1584
1702
|
/**
|
|
1585
1703
|
* Caches the position of the drop list.
|
|
@@ -1587,7 +1705,7 @@ class DropListRef {
|
|
|
1587
1705
|
* @return {?}
|
|
1588
1706
|
*/
|
|
1589
1707
|
_cacheOwnPosition() {
|
|
1590
|
-
this._clientRect = this.element.getBoundingClientRect();
|
|
1708
|
+
this._clientRect = coerceElement(this.element).getBoundingClientRect();
|
|
1591
1709
|
}
|
|
1592
1710
|
/**
|
|
1593
1711
|
* Refreshes the position cache of the items and sibling containers.
|
|
@@ -1597,7 +1715,11 @@ class DropListRef {
|
|
|
1597
1715
|
_cacheItemPositions() {
|
|
1598
1716
|
/** @type {?} */
|
|
1599
1717
|
const isHorizontal = this._orientation === 'horizontal';
|
|
1600
|
-
this._itemPositions = this._activeDraggables.map(
|
|
1718
|
+
this._itemPositions = this._activeDraggables.map((/**
|
|
1719
|
+
* @param {?} drag
|
|
1720
|
+
* @return {?}
|
|
1721
|
+
*/
|
|
1722
|
+
drag => {
|
|
1601
1723
|
/** @type {?} */
|
|
1602
1724
|
const elementToMeasure = this._dragDropRegistry.isDragging(drag) ?
|
|
1603
1725
|
// If the element is being dragged, we have to measure the
|
|
@@ -1622,10 +1744,15 @@ class DropListRef {
|
|
|
1622
1744
|
height: clientRect.height
|
|
1623
1745
|
}
|
|
1624
1746
|
};
|
|
1625
|
-
}).sort((
|
|
1747
|
+
})).sort((/**
|
|
1748
|
+
* @param {?} a
|
|
1749
|
+
* @param {?} b
|
|
1750
|
+
* @return {?}
|
|
1751
|
+
*/
|
|
1752
|
+
(a, b) => {
|
|
1626
1753
|
return isHorizontal ? a.clientRect.left - b.clientRect.left :
|
|
1627
1754
|
a.clientRect.top - b.clientRect.top;
|
|
1628
|
-
});
|
|
1755
|
+
}));
|
|
1629
1756
|
}
|
|
1630
1757
|
/**
|
|
1631
1758
|
* Resets the container to its initial state.
|
|
@@ -1635,8 +1762,16 @@ class DropListRef {
|
|
|
1635
1762
|
_reset() {
|
|
1636
1763
|
this._isDragging = false;
|
|
1637
1764
|
// TODO(crisbeto): may have to wait for the animations to finish.
|
|
1638
|
-
this._activeDraggables.forEach(
|
|
1639
|
-
|
|
1765
|
+
this._activeDraggables.forEach((/**
|
|
1766
|
+
* @param {?} item
|
|
1767
|
+
* @return {?}
|
|
1768
|
+
*/
|
|
1769
|
+
item => item.getRootElement().style.transform = ''));
|
|
1770
|
+
this._siblings.forEach((/**
|
|
1771
|
+
* @param {?} sibling
|
|
1772
|
+
* @return {?}
|
|
1773
|
+
*/
|
|
1774
|
+
sibling => sibling._stopReceiving(this)));
|
|
1640
1775
|
this._activeDraggables = [];
|
|
1641
1776
|
this._itemPositions = [];
|
|
1642
1777
|
this._previousSwap.drag = null;
|
|
@@ -1726,7 +1861,13 @@ class DropListRef {
|
|
|
1726
1861
|
_getItemIndexFromPointerPosition(item, pointerX, pointerY, delta) {
|
|
1727
1862
|
/** @type {?} */
|
|
1728
1863
|
const isHorizontal = this._orientation === 'horizontal';
|
|
1729
|
-
return findIndex(this._itemPositions, (
|
|
1864
|
+
return findIndex(this._itemPositions, (/**
|
|
1865
|
+
* @param {?} __0
|
|
1866
|
+
* @param {?} _
|
|
1867
|
+
* @param {?} array
|
|
1868
|
+
* @return {?}
|
|
1869
|
+
*/
|
|
1870
|
+
({ drag, clientRect }, _, array) => {
|
|
1730
1871
|
if (drag === item) {
|
|
1731
1872
|
// If there's only one item left in the container, it must be
|
|
1732
1873
|
// the dragged item itself so we use it as a reference.
|
|
@@ -1746,7 +1887,17 @@ class DropListRef {
|
|
|
1746
1887
|
// sub-pixel precision, whereas the pointer coordinates are rounded to pixels.
|
|
1747
1888
|
pointerX >= Math.floor(clientRect.left) && pointerX <= Math.floor(clientRect.right) :
|
|
1748
1889
|
pointerY >= Math.floor(clientRect.top) && pointerY <= Math.floor(clientRect.bottom);
|
|
1749
|
-
});
|
|
1890
|
+
}));
|
|
1891
|
+
}
|
|
1892
|
+
/**
|
|
1893
|
+
* Caches the current items in the list and their positions.
|
|
1894
|
+
* @private
|
|
1895
|
+
* @return {?}
|
|
1896
|
+
*/
|
|
1897
|
+
_cacheItems() {
|
|
1898
|
+
this._activeDraggables = this._draggables.slice();
|
|
1899
|
+
this._cacheItemPositions();
|
|
1900
|
+
this._cacheOwnPosition();
|
|
1750
1901
|
}
|
|
1751
1902
|
/**
|
|
1752
1903
|
* Checks whether the user's pointer is positioned over the container.
|
|
@@ -1766,7 +1917,11 @@ class DropListRef {
|
|
|
1766
1917
|
* @return {?}
|
|
1767
1918
|
*/
|
|
1768
1919
|
_getSiblingContainerFromPosition(item, x, y) {
|
|
1769
|
-
return this._siblings.find(
|
|
1920
|
+
return this._siblings.find((/**
|
|
1921
|
+
* @param {?} sibling
|
|
1922
|
+
* @return {?}
|
|
1923
|
+
*/
|
|
1924
|
+
sibling => sibling._canReceive(item, x, y)));
|
|
1770
1925
|
}
|
|
1771
1926
|
/**
|
|
1772
1927
|
* Checks whether the drop list can receive the passed-in item.
|
|
@@ -1780,19 +1935,21 @@ class DropListRef {
|
|
|
1780
1935
|
return false;
|
|
1781
1936
|
}
|
|
1782
1937
|
/** @type {?} */
|
|
1783
|
-
const elementFromPoint = this._document.elementFromPoint(x, y);
|
|
1938
|
+
const elementFromPoint = (/** @type {?} */ (this._document.elementFromPoint(x, y)));
|
|
1784
1939
|
// If there's no element at the pointer position, then
|
|
1785
1940
|
// the client rect is probably scrolled out of the view.
|
|
1786
1941
|
if (!elementFromPoint) {
|
|
1787
1942
|
return false;
|
|
1788
1943
|
}
|
|
1944
|
+
/** @type {?} */
|
|
1945
|
+
const nativeElement = coerceElement(this.element);
|
|
1789
1946
|
// The `ClientRect`, that we're using to find the container over which the user is
|
|
1790
1947
|
// hovering, doesn't give us any information on whether the element has been scrolled
|
|
1791
1948
|
// out of the view or whether it's overlapping with other containers. This means that
|
|
1792
1949
|
// we could end up transferring the item into a container that's invisible or is positioned
|
|
1793
1950
|
// below another one. We use the result from `elementFromPoint` to get the top-most element
|
|
1794
1951
|
// at the pointer position and to find whether it's one of the intersecting drop containers.
|
|
1795
|
-
return elementFromPoint ===
|
|
1952
|
+
return elementFromPoint === nativeElement || nativeElement.contains(elementFromPoint);
|
|
1796
1953
|
}
|
|
1797
1954
|
/**
|
|
1798
1955
|
* Called by one of the connected drop lists when a dragging sequence has started.
|
|
@@ -1859,7 +2016,7 @@ function isInsideClientRect(clientRect, x, y) {
|
|
|
1859
2016
|
|
|
1860
2017
|
/**
|
|
1861
2018
|
* @fileoverview added by tsickle
|
|
1862
|
-
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2019
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1863
2020
|
*/
|
|
1864
2021
|
/**
|
|
1865
2022
|
* Event options that can be used to bind an active, capturing event.
|
|
@@ -1915,11 +2072,15 @@ class DragDropRegistry {
|
|
|
1915
2072
|
* Event listener that will prevent the default browser action while the user is dragging.
|
|
1916
2073
|
* @param event Event whose default action should be prevented.
|
|
1917
2074
|
*/
|
|
1918
|
-
this._preventDefaultWhileDragging = (
|
|
2075
|
+
this._preventDefaultWhileDragging = (/**
|
|
2076
|
+
* @param {?} event
|
|
2077
|
+
* @return {?}
|
|
2078
|
+
*/
|
|
2079
|
+
(event) => {
|
|
1919
2080
|
if (this._activeDragInstances.size) {
|
|
1920
2081
|
event.preventDefault();
|
|
1921
2082
|
}
|
|
1922
|
-
};
|
|
2083
|
+
});
|
|
1923
2084
|
this._document = _document;
|
|
1924
2085
|
}
|
|
1925
2086
|
/**
|
|
@@ -1946,11 +2107,14 @@ class DragDropRegistry {
|
|
|
1946
2107
|
// won't preventDefault on a dynamically-added `touchmove` listener.
|
|
1947
2108
|
// See https://bugs.webkit.org/show_bug.cgi?id=184250.
|
|
1948
2109
|
if (this._dragInstances.size === 1) {
|
|
1949
|
-
this._ngZone.runOutsideAngular((
|
|
2110
|
+
this._ngZone.runOutsideAngular((/**
|
|
2111
|
+
* @return {?}
|
|
2112
|
+
*/
|
|
2113
|
+
() => {
|
|
1950
2114
|
// The event handler has to be explicitly active,
|
|
1951
2115
|
// because newer browsers make it passive by default.
|
|
1952
2116
|
this._document.addEventListener('touchmove', this._preventDefaultWhileDragging, activeCapturingEventOptions);
|
|
1953
|
-
});
|
|
2117
|
+
}));
|
|
1954
2118
|
}
|
|
1955
2119
|
}
|
|
1956
2120
|
/**
|
|
@@ -1993,11 +2157,19 @@ class DragDropRegistry {
|
|
|
1993
2157
|
// use `preventDefault` to prevent the page from scrolling while the user is dragging.
|
|
1994
2158
|
this._globalListeners
|
|
1995
2159
|
.set(moveEvent, {
|
|
1996
|
-
handler: (
|
|
2160
|
+
handler: (/**
|
|
2161
|
+
* @param {?} e
|
|
2162
|
+
* @return {?}
|
|
2163
|
+
*/
|
|
2164
|
+
(e) => this.pointerMove.next((/** @type {?} */ (e)))),
|
|
1997
2165
|
options: activeCapturingEventOptions
|
|
1998
2166
|
})
|
|
1999
2167
|
.set(upEvent, {
|
|
2000
|
-
handler: (
|
|
2168
|
+
handler: (/**
|
|
2169
|
+
* @param {?} e
|
|
2170
|
+
* @return {?}
|
|
2171
|
+
*/
|
|
2172
|
+
(e) => this.pointerUp.next((/** @type {?} */ (e)))),
|
|
2001
2173
|
options: true
|
|
2002
2174
|
})
|
|
2003
2175
|
// Preventing the default action on `mousemove` isn't enough to disable text selection
|
|
@@ -2016,11 +2188,19 @@ class DragDropRegistry {
|
|
|
2016
2188
|
options: activeCapturingEventOptions
|
|
2017
2189
|
});
|
|
2018
2190
|
}
|
|
2019
|
-
this._ngZone.runOutsideAngular((
|
|
2020
|
-
|
|
2191
|
+
this._ngZone.runOutsideAngular((/**
|
|
2192
|
+
* @return {?}
|
|
2193
|
+
*/
|
|
2194
|
+
() => {
|
|
2195
|
+
this._globalListeners.forEach((/**
|
|
2196
|
+
* @param {?} config
|
|
2197
|
+
* @param {?} name
|
|
2198
|
+
* @return {?}
|
|
2199
|
+
*/
|
|
2200
|
+
(config, name) => {
|
|
2021
2201
|
this._document.addEventListener(name, config.handler, config.options);
|
|
2022
|
-
});
|
|
2023
|
-
});
|
|
2202
|
+
}));
|
|
2203
|
+
}));
|
|
2024
2204
|
}
|
|
2025
2205
|
}
|
|
2026
2206
|
/**
|
|
@@ -2050,14 +2230,26 @@ class DragDropRegistry {
|
|
|
2050
2230
|
* @return {?}
|
|
2051
2231
|
*/
|
|
2052
2232
|
getDropContainer(id) {
|
|
2053
|
-
return Array.from(this._dropInstances).find(
|
|
2233
|
+
return Array.from(this._dropInstances).find((/**
|
|
2234
|
+
* @param {?} instance
|
|
2235
|
+
* @return {?}
|
|
2236
|
+
*/
|
|
2237
|
+
instance => instance.id === id));
|
|
2054
2238
|
}
|
|
2055
2239
|
/**
|
|
2056
2240
|
* @return {?}
|
|
2057
2241
|
*/
|
|
2058
2242
|
ngOnDestroy() {
|
|
2059
|
-
this._dragInstances.forEach(
|
|
2060
|
-
|
|
2243
|
+
this._dragInstances.forEach((/**
|
|
2244
|
+
* @param {?} instance
|
|
2245
|
+
* @return {?}
|
|
2246
|
+
*/
|
|
2247
|
+
instance => this.removeDragItem(instance)));
|
|
2248
|
+
this._dropInstances.forEach((/**
|
|
2249
|
+
* @param {?} instance
|
|
2250
|
+
* @return {?}
|
|
2251
|
+
*/
|
|
2252
|
+
instance => this.removeDropContainer(instance)));
|
|
2061
2253
|
this._clearGlobalListeners();
|
|
2062
2254
|
this.pointerMove.complete();
|
|
2063
2255
|
this.pointerUp.complete();
|
|
@@ -2068,9 +2260,14 @@ class DragDropRegistry {
|
|
|
2068
2260
|
* @return {?}
|
|
2069
2261
|
*/
|
|
2070
2262
|
_clearGlobalListeners() {
|
|
2071
|
-
this._globalListeners.forEach((
|
|
2263
|
+
this._globalListeners.forEach((/**
|
|
2264
|
+
* @param {?} config
|
|
2265
|
+
* @param {?} name
|
|
2266
|
+
* @return {?}
|
|
2267
|
+
*/
|
|
2268
|
+
(config, name) => {
|
|
2072
2269
|
this._document.removeEventListener(name, config.handler, config.options);
|
|
2073
|
-
});
|
|
2270
|
+
}));
|
|
2074
2271
|
this._globalListeners.clear();
|
|
2075
2272
|
}
|
|
2076
2273
|
}
|
|
@@ -2082,11 +2279,11 @@ DragDropRegistry.ctorParameters = () => [
|
|
|
2082
2279
|
{ type: NgZone },
|
|
2083
2280
|
{ type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] }
|
|
2084
2281
|
];
|
|
2085
|
-
/** @nocollapse */ DragDropRegistry.ngInjectableDef =
|
|
2282
|
+
/** @nocollapse */ DragDropRegistry.ngInjectableDef = ɵɵdefineInjectable({ factory: function DragDropRegistry_Factory() { return new DragDropRegistry(ɵɵinject(NgZone), ɵɵinject(DOCUMENT)); }, token: DragDropRegistry, providedIn: "root" });
|
|
2086
2283
|
|
|
2087
2284
|
/**
|
|
2088
2285
|
* @fileoverview added by tsickle
|
|
2089
|
-
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2286
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2090
2287
|
*/
|
|
2091
2288
|
/**
|
|
2092
2289
|
* Default configuration to be used when creating a `DragRef`.
|
|
@@ -2142,11 +2339,11 @@ DragDrop.ctorParameters = () => [
|
|
|
2142
2339
|
{ type: ViewportRuler },
|
|
2143
2340
|
{ type: DragDropRegistry }
|
|
2144
2341
|
];
|
|
2145
|
-
/** @nocollapse */ DragDrop.ngInjectableDef =
|
|
2342
|
+
/** @nocollapse */ DragDrop.ngInjectableDef = ɵɵdefineInjectable({ factory: function DragDrop_Factory() { return new DragDrop(ɵɵinject(DOCUMENT), ɵɵinject(NgZone), ɵɵinject(ViewportRuler), ɵɵinject(DragDropRegistry)); }, token: DragDrop, providedIn: "root" });
|
|
2146
2343
|
|
|
2147
2344
|
/**
|
|
2148
2345
|
* @fileoverview added by tsickle
|
|
2149
|
-
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2346
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2150
2347
|
*/
|
|
2151
2348
|
/**
|
|
2152
2349
|
* Injection token that is used to provide a CdkDropList instance to CdkDrag.
|
|
@@ -2165,12 +2362,12 @@ const CDK_DROP_LIST_CONTAINER = CDK_DROP_LIST;
|
|
|
2165
2362
|
|
|
2166
2363
|
/**
|
|
2167
2364
|
* @fileoverview added by tsickle
|
|
2168
|
-
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2365
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2169
2366
|
*/
|
|
2170
2367
|
|
|
2171
2368
|
/**
|
|
2172
2369
|
* @fileoverview added by tsickle
|
|
2173
|
-
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2370
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2174
2371
|
*/
|
|
2175
2372
|
/**
|
|
2176
2373
|
* Injection token that can be used for a `CdkDrag` to provide itself as a parent to the
|
|
@@ -2183,7 +2380,7 @@ const CDK_DRAG_PARENT = new InjectionToken('CDK_DRAG_PARENT');
|
|
|
2183
2380
|
|
|
2184
2381
|
/**
|
|
2185
2382
|
* @fileoverview added by tsickle
|
|
2186
|
-
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2383
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2187
2384
|
*/
|
|
2188
2385
|
/**
|
|
2189
2386
|
* Handle that can be used to drag and CdkDrag instance.
|
|
@@ -2242,7 +2439,7 @@ CdkDragHandle.propDecorators = {
|
|
|
2242
2439
|
|
|
2243
2440
|
/**
|
|
2244
2441
|
* @fileoverview added by tsickle
|
|
2245
|
-
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2442
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2246
2443
|
*/
|
|
2247
2444
|
/**
|
|
2248
2445
|
* Element that will be used as a template for the placeholder of a CdkDrag when
|
|
@@ -2272,7 +2469,7 @@ CdkDragPlaceholder.propDecorators = {
|
|
|
2272
2469
|
|
|
2273
2470
|
/**
|
|
2274
2471
|
* @fileoverview added by tsickle
|
|
2275
|
-
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2472
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2276
2473
|
*/
|
|
2277
2474
|
/**
|
|
2278
2475
|
* Element that will be used as a template for the preview
|
|
@@ -2302,7 +2499,7 @@ CdkDragPreview.propDecorators = {
|
|
|
2302
2499
|
|
|
2303
2500
|
/**
|
|
2304
2501
|
* @fileoverview added by tsickle
|
|
2305
|
-
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2502
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2306
2503
|
*/
|
|
2307
2504
|
/**
|
|
2308
2505
|
* Injection token that can be used to configure the behavior of `CdkDrag`.
|
|
@@ -2378,23 +2575,53 @@ class CdkDrag {
|
|
|
2378
2575
|
* Emits as the user is dragging the item. Use with caution,
|
|
2379
2576
|
* because this event will fire for every pixel that the user has dragged.
|
|
2380
2577
|
*/
|
|
2381
|
-
this.moved = new Observable((
|
|
2578
|
+
this.moved = new Observable((/**
|
|
2579
|
+
* @param {?} observer
|
|
2580
|
+
* @return {?}
|
|
2581
|
+
*/
|
|
2582
|
+
(observer) => {
|
|
2382
2583
|
/** @type {?} */
|
|
2383
|
-
const subscription = this._dragRef.moved.pipe(map(
|
|
2584
|
+
const subscription = this._dragRef.moved.pipe(map((/**
|
|
2585
|
+
* @param {?} movedEvent
|
|
2586
|
+
* @return {?}
|
|
2587
|
+
*/
|
|
2588
|
+
movedEvent => ({
|
|
2384
2589
|
source: this,
|
|
2385
2590
|
pointerPosition: movedEvent.pointerPosition,
|
|
2386
2591
|
event: movedEvent.event,
|
|
2387
|
-
delta: movedEvent.delta
|
|
2388
|
-
|
|
2389
|
-
|
|
2592
|
+
delta: movedEvent.delta,
|
|
2593
|
+
distance: movedEvent.distance
|
|
2594
|
+
})))).subscribe(observer);
|
|
2595
|
+
return (/**
|
|
2596
|
+
* @return {?}
|
|
2597
|
+
*/
|
|
2598
|
+
() => {
|
|
2390
2599
|
subscription.unsubscribe();
|
|
2391
|
-
};
|
|
2392
|
-
});
|
|
2600
|
+
});
|
|
2601
|
+
}));
|
|
2393
2602
|
this._dragRef = dragDrop.createDrag(element, config);
|
|
2394
2603
|
this._dragRef.data = this;
|
|
2395
2604
|
this._syncInputs(this._dragRef);
|
|
2396
2605
|
this._handleEvents(this._dragRef);
|
|
2397
2606
|
}
|
|
2607
|
+
/**
|
|
2608
|
+
* Selector that will be used to determine the element to which the draggable's position will
|
|
2609
|
+
* be constrained. Matching starts from the element's parent and goes up the DOM until a matching
|
|
2610
|
+
* element has been found
|
|
2611
|
+
* @deprecated Use `boundaryElement` instead.
|
|
2612
|
+
* \@breaking-change 9.0.0
|
|
2613
|
+
* @return {?}
|
|
2614
|
+
*/
|
|
2615
|
+
get boundaryElementSelector() {
|
|
2616
|
+
return typeof this.boundaryElement === 'string' ? this.boundaryElement : (/** @type {?} */ (undefined));
|
|
2617
|
+
}
|
|
2618
|
+
/**
|
|
2619
|
+
* @param {?} selector
|
|
2620
|
+
* @return {?}
|
|
2621
|
+
*/
|
|
2622
|
+
set boundaryElementSelector(selector) {
|
|
2623
|
+
this.boundaryElement = selector;
|
|
2624
|
+
}
|
|
2398
2625
|
/**
|
|
2399
2626
|
* Whether starting to drag this element is disabled.
|
|
2400
2627
|
* @return {?}
|
|
@@ -2449,33 +2676,60 @@ class CdkDrag {
|
|
|
2449
2676
|
// their original DOM position and then they get transferred to the portal.
|
|
2450
2677
|
this._ngZone.onStable.asObservable()
|
|
2451
2678
|
.pipe(take(1), takeUntil(this._destroyed))
|
|
2452
|
-
.subscribe((
|
|
2679
|
+
.subscribe((/**
|
|
2680
|
+
* @return {?}
|
|
2681
|
+
*/
|
|
2682
|
+
() => {
|
|
2453
2683
|
this._updateRootElement();
|
|
2454
2684
|
// Listen for any newly-added handles.
|
|
2455
2685
|
this._handles.changes.pipe(startWith(this._handles),
|
|
2456
2686
|
// Sync the new handles with the DragRef.
|
|
2457
|
-
tap((
|
|
2687
|
+
tap((/**
|
|
2688
|
+
* @param {?} handles
|
|
2689
|
+
* @return {?}
|
|
2690
|
+
*/
|
|
2691
|
+
(handles) => {
|
|
2458
2692
|
/** @type {?} */
|
|
2459
2693
|
const childHandleElements = handles
|
|
2460
|
-
.filter(
|
|
2461
|
-
|
|
2694
|
+
.filter((/**
|
|
2695
|
+
* @param {?} handle
|
|
2696
|
+
* @return {?}
|
|
2697
|
+
*/
|
|
2698
|
+
handle => handle._parentDrag === this))
|
|
2699
|
+
.map((/**
|
|
2700
|
+
* @param {?} handle
|
|
2701
|
+
* @return {?}
|
|
2702
|
+
*/
|
|
2703
|
+
handle => handle.element));
|
|
2462
2704
|
this._dragRef.withHandles(childHandleElements);
|
|
2463
|
-
}),
|
|
2705
|
+
})),
|
|
2464
2706
|
// Listen if the state of any of the handles changes.
|
|
2465
|
-
switchMap((
|
|
2466
|
-
|
|
2467
|
-
|
|
2707
|
+
switchMap((/**
|
|
2708
|
+
* @param {?} handles
|
|
2709
|
+
* @return {?}
|
|
2710
|
+
*/
|
|
2711
|
+
(handles) => {
|
|
2712
|
+
return merge(...handles.map((/**
|
|
2713
|
+
* @param {?} item
|
|
2714
|
+
* @return {?}
|
|
2715
|
+
*/
|
|
2716
|
+
item => item._stateChanges)));
|
|
2717
|
+
})), takeUntil(this._destroyed)).subscribe((/**
|
|
2718
|
+
* @param {?} handleInstance
|
|
2719
|
+
* @return {?}
|
|
2720
|
+
*/
|
|
2721
|
+
handleInstance => {
|
|
2468
2722
|
// Enabled/disable the handle that changed in the DragRef.
|
|
2469
2723
|
/** @type {?} */
|
|
2470
2724
|
const dragRef = this._dragRef;
|
|
2471
2725
|
/** @type {?} */
|
|
2472
2726
|
const handle = handleInstance.element.nativeElement;
|
|
2473
2727
|
handleInstance.disabled ? dragRef.disableHandle(handle) : dragRef.enableHandle(handle);
|
|
2474
|
-
});
|
|
2728
|
+
}));
|
|
2475
2729
|
if (this.freeDragPosition) {
|
|
2476
2730
|
this._dragRef.setFreeDragPosition(this.freeDragPosition);
|
|
2477
2731
|
}
|
|
2478
|
-
});
|
|
2732
|
+
}));
|
|
2479
2733
|
}
|
|
2480
2734
|
/**
|
|
2481
2735
|
* @param {?} changes
|
|
@@ -2485,7 +2739,7 @@ class CdkDrag {
|
|
|
2485
2739
|
/** @type {?} */
|
|
2486
2740
|
const rootSelectorChange = changes['rootElementSelector'];
|
|
2487
2741
|
/** @type {?} */
|
|
2488
|
-
const positionChange = changes['
|
|
2742
|
+
const positionChange = changes['freeDragPosition'];
|
|
2489
2743
|
// We don't have to react to the first change since it's being
|
|
2490
2744
|
// handled in `ngAfterViewInit` where it needs to be deferred.
|
|
2491
2745
|
if (rootSelectorChange && !rootSelectorChange.firstChange) {
|
|
@@ -2522,14 +2776,25 @@ class CdkDrag {
|
|
|
2522
2776
|
this._dragRef.withRootElement(rootElement || element);
|
|
2523
2777
|
}
|
|
2524
2778
|
/**
|
|
2525
|
-
* Gets the boundary element, based on the `
|
|
2779
|
+
* Gets the boundary element, based on the `boundaryElement` value.
|
|
2526
2780
|
* @private
|
|
2527
2781
|
* @return {?}
|
|
2528
2782
|
*/
|
|
2529
2783
|
_getBoundaryElement() {
|
|
2530
2784
|
/** @type {?} */
|
|
2531
|
-
const
|
|
2532
|
-
|
|
2785
|
+
const boundary = this.boundaryElement;
|
|
2786
|
+
if (!boundary) {
|
|
2787
|
+
return null;
|
|
2788
|
+
}
|
|
2789
|
+
if (typeof boundary === 'string') {
|
|
2790
|
+
return getClosestMatchingAncestor(this.element.nativeElement, boundary);
|
|
2791
|
+
}
|
|
2792
|
+
/** @type {?} */
|
|
2793
|
+
const element = coerceElement(boundary);
|
|
2794
|
+
if (isDevMode() && !element.contains(this.element.nativeElement)) {
|
|
2795
|
+
throw Error('Draggable element is not inside of the node passed into cdkDragBoundary.');
|
|
2796
|
+
}
|
|
2797
|
+
return element;
|
|
2533
2798
|
}
|
|
2534
2799
|
/**
|
|
2535
2800
|
* Syncs the inputs of the CdkDrag with the options of the underlying DragRef.
|
|
@@ -2538,7 +2803,10 @@ class CdkDrag {
|
|
|
2538
2803
|
* @return {?}
|
|
2539
2804
|
*/
|
|
2540
2805
|
_syncInputs(ref) {
|
|
2541
|
-
ref.beforeStarted.subscribe((
|
|
2806
|
+
ref.beforeStarted.subscribe((/**
|
|
2807
|
+
* @return {?}
|
|
2808
|
+
*/
|
|
2809
|
+
() => {
|
|
2542
2810
|
if (!ref.isDragging()) {
|
|
2543
2811
|
/** @type {?} */
|
|
2544
2812
|
const dir = this._dir;
|
|
@@ -2566,7 +2834,7 @@ class CdkDrag {
|
|
|
2566
2834
|
ref.withDirection(dir.value);
|
|
2567
2835
|
}
|
|
2568
2836
|
}
|
|
2569
|
-
});
|
|
2837
|
+
}));
|
|
2570
2838
|
}
|
|
2571
2839
|
/**
|
|
2572
2840
|
* Handles the events from the underlying `DragRef`.
|
|
@@ -2575,43 +2843,67 @@ class CdkDrag {
|
|
|
2575
2843
|
* @return {?}
|
|
2576
2844
|
*/
|
|
2577
2845
|
_handleEvents(ref) {
|
|
2578
|
-
ref.started.subscribe((
|
|
2846
|
+
ref.started.subscribe((/**
|
|
2847
|
+
* @return {?}
|
|
2848
|
+
*/
|
|
2849
|
+
() => {
|
|
2579
2850
|
this.started.emit({ source: this });
|
|
2580
2851
|
// Since all of these events run outside of change detection,
|
|
2581
2852
|
// we need to ensure that everything is marked correctly.
|
|
2582
2853
|
this._changeDetectorRef.markForCheck();
|
|
2583
|
-
});
|
|
2584
|
-
ref.released.subscribe((
|
|
2854
|
+
}));
|
|
2855
|
+
ref.released.subscribe((/**
|
|
2856
|
+
* @return {?}
|
|
2857
|
+
*/
|
|
2858
|
+
() => {
|
|
2585
2859
|
this.released.emit({ source: this });
|
|
2586
|
-
});
|
|
2587
|
-
ref.ended.subscribe((
|
|
2588
|
-
|
|
2860
|
+
}));
|
|
2861
|
+
ref.ended.subscribe((/**
|
|
2862
|
+
* @param {?} event
|
|
2863
|
+
* @return {?}
|
|
2864
|
+
*/
|
|
2865
|
+
event => {
|
|
2866
|
+
this.ended.emit({ source: this, distance: event.distance });
|
|
2589
2867
|
// Since all of these events run outside of change detection,
|
|
2590
2868
|
// we need to ensure that everything is marked correctly.
|
|
2591
2869
|
this._changeDetectorRef.markForCheck();
|
|
2592
|
-
});
|
|
2593
|
-
ref.entered.subscribe(
|
|
2870
|
+
}));
|
|
2871
|
+
ref.entered.subscribe((/**
|
|
2872
|
+
* @param {?} event
|
|
2873
|
+
* @return {?}
|
|
2874
|
+
*/
|
|
2875
|
+
event => {
|
|
2594
2876
|
this.entered.emit({
|
|
2595
2877
|
container: event.container.data,
|
|
2596
|
-
item: this
|
|
2878
|
+
item: this,
|
|
2879
|
+
currentIndex: event.currentIndex
|
|
2597
2880
|
});
|
|
2598
|
-
});
|
|
2599
|
-
ref.exited.subscribe(
|
|
2881
|
+
}));
|
|
2882
|
+
ref.exited.subscribe((/**
|
|
2883
|
+
* @param {?} event
|
|
2884
|
+
* @return {?}
|
|
2885
|
+
*/
|
|
2886
|
+
event => {
|
|
2600
2887
|
this.exited.emit({
|
|
2601
2888
|
container: event.container.data,
|
|
2602
2889
|
item: this
|
|
2603
2890
|
});
|
|
2604
|
-
});
|
|
2605
|
-
ref.dropped.subscribe(
|
|
2891
|
+
}));
|
|
2892
|
+
ref.dropped.subscribe((/**
|
|
2893
|
+
* @param {?} event
|
|
2894
|
+
* @return {?}
|
|
2895
|
+
*/
|
|
2896
|
+
event => {
|
|
2606
2897
|
this.dropped.emit({
|
|
2607
2898
|
previousIndex: event.previousIndex,
|
|
2608
2899
|
currentIndex: event.currentIndex,
|
|
2609
2900
|
previousContainer: event.previousContainer.data,
|
|
2610
2901
|
container: event.container.data,
|
|
2611
2902
|
isPointerOverContainer: event.isPointerOverContainer,
|
|
2612
|
-
item: this
|
|
2903
|
+
item: this,
|
|
2904
|
+
distance: event.distance
|
|
2613
2905
|
});
|
|
2614
|
-
});
|
|
2906
|
+
}));
|
|
2615
2907
|
}
|
|
2616
2908
|
}
|
|
2617
2909
|
CdkDrag.decorators = [
|
|
@@ -2645,7 +2937,7 @@ CdkDrag.propDecorators = {
|
|
|
2645
2937
|
data: [{ type: Input, args: ['cdkDragData',] }],
|
|
2646
2938
|
lockAxis: [{ type: Input, args: ['cdkDragLockAxis',] }],
|
|
2647
2939
|
rootElementSelector: [{ type: Input, args: ['cdkDragRootElement',] }],
|
|
2648
|
-
|
|
2940
|
+
boundaryElement: [{ type: Input, args: ['cdkDragBoundary',] }],
|
|
2649
2941
|
dragStartDelay: [{ type: Input, args: ['cdkDragStartDelay',] }],
|
|
2650
2942
|
freeDragPosition: [{ type: Input, args: ['cdkDragFreeDragPosition',] }],
|
|
2651
2943
|
disabled: [{ type: Input, args: ['cdkDragDisabled',] }],
|
|
@@ -2680,7 +2972,7 @@ function getClosestMatchingAncestor(element, selector) {
|
|
|
2680
2972
|
|
|
2681
2973
|
/**
|
|
2682
2974
|
* @fileoverview added by tsickle
|
|
2683
|
-
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2975
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2684
2976
|
*/
|
|
2685
2977
|
/**
|
|
2686
2978
|
* Declaratively connects sibling `cdkDropList` instances together. All of the `cdkDropList`
|
|
@@ -2728,7 +3020,7 @@ CdkDropListGroup.propDecorators = {
|
|
|
2728
3020
|
|
|
2729
3021
|
/**
|
|
2730
3022
|
* @fileoverview added by tsickle
|
|
2731
|
-
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
3023
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2732
3024
|
*/
|
|
2733
3025
|
/**
|
|
2734
3026
|
* Counter used to generate unique ids for drop zones.
|
|
@@ -2781,7 +3073,10 @@ class CdkDropList {
|
|
|
2781
3073
|
* Function that is used to determine whether an item
|
|
2782
3074
|
* is allowed to be moved into a drop container.
|
|
2783
3075
|
*/
|
|
2784
|
-
this.enterPredicate = (
|
|
3076
|
+
this.enterPredicate = (/**
|
|
3077
|
+
* @return {?}
|
|
3078
|
+
*/
|
|
3079
|
+
() => true);
|
|
2785
3080
|
/**
|
|
2786
3081
|
* Emits when the user drops an item inside the container.
|
|
2787
3082
|
*/
|
|
@@ -2801,9 +3096,14 @@ class CdkDropList {
|
|
|
2801
3096
|
this.sorted = new EventEmitter();
|
|
2802
3097
|
this._dropListRef = dragDrop.createDropList(element);
|
|
2803
3098
|
this._dropListRef.data = this;
|
|
2804
|
-
this._dropListRef.enterPredicate = (
|
|
3099
|
+
this._dropListRef.enterPredicate = (/**
|
|
3100
|
+
* @param {?} drag
|
|
3101
|
+
* @param {?} drop
|
|
3102
|
+
* @return {?}
|
|
3103
|
+
*/
|
|
3104
|
+
(drag, drop) => {
|
|
2805
3105
|
return this.enterPredicate(drag.data, drop.data);
|
|
2806
|
-
};
|
|
3106
|
+
});
|
|
2807
3107
|
this._syncInputs(this._dropListRef);
|
|
2808
3108
|
this._handleEvents(this._dropListRef);
|
|
2809
3109
|
CdkDropList._dropLists.push(this);
|
|
@@ -2843,9 +3143,17 @@ class CdkDropList {
|
|
|
2843
3143
|
ngAfterContentInit() {
|
|
2844
3144
|
this._draggables.changes
|
|
2845
3145
|
.pipe(startWith(this._draggables), takeUntil(this._destroyed))
|
|
2846
|
-
.subscribe((
|
|
2847
|
-
|
|
2848
|
-
|
|
3146
|
+
.subscribe((/**
|
|
3147
|
+
* @param {?} items
|
|
3148
|
+
* @return {?}
|
|
3149
|
+
*/
|
|
3150
|
+
(items) => {
|
|
3151
|
+
this._dropListRef.withItems(items.map((/**
|
|
3152
|
+
* @param {?} drag
|
|
3153
|
+
* @return {?}
|
|
3154
|
+
*/
|
|
3155
|
+
drag => drag._dragRef)));
|
|
3156
|
+
}));
|
|
2849
3157
|
}
|
|
2850
3158
|
/**
|
|
2851
3159
|
* @return {?}
|
|
@@ -2951,28 +3259,55 @@ class CdkDropList {
|
|
|
2951
3259
|
if (this._dir) {
|
|
2952
3260
|
this._dir.change
|
|
2953
3261
|
.pipe(startWith(this._dir.value), takeUntil(this._destroyed))
|
|
2954
|
-
.subscribe(
|
|
3262
|
+
.subscribe((/**
|
|
3263
|
+
* @param {?} value
|
|
3264
|
+
* @return {?}
|
|
3265
|
+
*/
|
|
3266
|
+
value => ref.withDirection(value)));
|
|
2955
3267
|
}
|
|
2956
|
-
ref.beforeStarted.subscribe((
|
|
3268
|
+
ref.beforeStarted.subscribe((/**
|
|
3269
|
+
* @return {?}
|
|
3270
|
+
*/
|
|
3271
|
+
() => {
|
|
2957
3272
|
/** @type {?} */
|
|
2958
|
-
const siblings = coerceArray(this.connectedTo).map(
|
|
3273
|
+
const siblings = coerceArray(this.connectedTo).map((/**
|
|
3274
|
+
* @param {?} drop
|
|
3275
|
+
* @return {?}
|
|
3276
|
+
*/
|
|
3277
|
+
drop => {
|
|
2959
3278
|
return typeof drop === 'string' ?
|
|
2960
|
-
(/** @type {?} */ (CdkDropList._dropLists.find(
|
|
2961
|
-
|
|
3279
|
+
(/** @type {?} */ (CdkDropList._dropLists.find((/**
|
|
3280
|
+
* @param {?} list
|
|
3281
|
+
* @return {?}
|
|
3282
|
+
*/
|
|
3283
|
+
list => list.id === drop)))) : drop;
|
|
3284
|
+
}));
|
|
2962
3285
|
if (this._group) {
|
|
2963
|
-
this._group._items.forEach(
|
|
3286
|
+
this._group._items.forEach((/**
|
|
3287
|
+
* @param {?} drop
|
|
3288
|
+
* @return {?}
|
|
3289
|
+
*/
|
|
3290
|
+
drop => {
|
|
2964
3291
|
if (siblings.indexOf(drop) === -1) {
|
|
2965
3292
|
siblings.push(drop);
|
|
2966
3293
|
}
|
|
2967
|
-
});
|
|
3294
|
+
}));
|
|
2968
3295
|
}
|
|
2969
3296
|
ref.disabled = this.disabled;
|
|
2970
3297
|
ref.lockAxis = this.lockAxis;
|
|
2971
3298
|
ref.sortingDisabled = this.sortingDisabled;
|
|
2972
3299
|
ref
|
|
2973
|
-
.connectedTo(siblings.filter(
|
|
3300
|
+
.connectedTo(siblings.filter((/**
|
|
3301
|
+
* @param {?} drop
|
|
3302
|
+
* @return {?}
|
|
3303
|
+
*/
|
|
3304
|
+
drop => drop && drop !== this)).map((/**
|
|
3305
|
+
* @param {?} list
|
|
3306
|
+
* @return {?}
|
|
3307
|
+
*/
|
|
3308
|
+
list => list._dropListRef)))
|
|
2974
3309
|
.withOrientation(this.orientation);
|
|
2975
|
-
});
|
|
3310
|
+
}));
|
|
2976
3311
|
}
|
|
2977
3312
|
/**
|
|
2978
3313
|
* Handles events from the underlying DropListRef.
|
|
@@ -2981,43 +3316,64 @@ class CdkDropList {
|
|
|
2981
3316
|
* @return {?}
|
|
2982
3317
|
*/
|
|
2983
3318
|
_handleEvents(ref) {
|
|
2984
|
-
ref.beforeStarted.subscribe((
|
|
3319
|
+
ref.beforeStarted.subscribe((/**
|
|
3320
|
+
* @return {?}
|
|
3321
|
+
*/
|
|
3322
|
+
() => {
|
|
2985
3323
|
this._changeDetectorRef.markForCheck();
|
|
2986
|
-
});
|
|
2987
|
-
ref.entered.subscribe(
|
|
3324
|
+
}));
|
|
3325
|
+
ref.entered.subscribe((/**
|
|
3326
|
+
* @param {?} event
|
|
3327
|
+
* @return {?}
|
|
3328
|
+
*/
|
|
3329
|
+
event => {
|
|
2988
3330
|
this.entered.emit({
|
|
2989
3331
|
container: this,
|
|
2990
|
-
item: event.item.data
|
|
3332
|
+
item: event.item.data,
|
|
3333
|
+
currentIndex: event.currentIndex
|
|
2991
3334
|
});
|
|
2992
|
-
});
|
|
2993
|
-
ref.exited.subscribe(
|
|
3335
|
+
}));
|
|
3336
|
+
ref.exited.subscribe((/**
|
|
3337
|
+
* @param {?} event
|
|
3338
|
+
* @return {?}
|
|
3339
|
+
*/
|
|
3340
|
+
event => {
|
|
2994
3341
|
this.exited.emit({
|
|
2995
3342
|
container: this,
|
|
2996
3343
|
item: event.item.data
|
|
2997
3344
|
});
|
|
2998
3345
|
this._changeDetectorRef.markForCheck();
|
|
2999
|
-
});
|
|
3000
|
-
ref.sorted.subscribe(
|
|
3346
|
+
}));
|
|
3347
|
+
ref.sorted.subscribe((/**
|
|
3348
|
+
* @param {?} event
|
|
3349
|
+
* @return {?}
|
|
3350
|
+
*/
|
|
3351
|
+
event => {
|
|
3001
3352
|
this.sorted.emit({
|
|
3002
3353
|
previousIndex: event.previousIndex,
|
|
3003
3354
|
currentIndex: event.currentIndex,
|
|
3004
3355
|
container: this,
|
|
3005
3356
|
item: event.item.data
|
|
3006
3357
|
});
|
|
3007
|
-
});
|
|
3008
|
-
ref.dropped.subscribe(
|
|
3358
|
+
}));
|
|
3359
|
+
ref.dropped.subscribe((/**
|
|
3360
|
+
* @param {?} event
|
|
3361
|
+
* @return {?}
|
|
3362
|
+
*/
|
|
3363
|
+
event => {
|
|
3009
3364
|
this.dropped.emit({
|
|
3010
3365
|
previousIndex: event.previousIndex,
|
|
3011
3366
|
currentIndex: event.currentIndex,
|
|
3012
3367
|
previousContainer: event.previousContainer.data,
|
|
3013
3368
|
container: event.container.data,
|
|
3014
3369
|
item: event.item.data,
|
|
3015
|
-
isPointerOverContainer: event.isPointerOverContainer
|
|
3370
|
+
isPointerOverContainer: event.isPointerOverContainer,
|
|
3371
|
+
distance: event.distance
|
|
3016
3372
|
});
|
|
3017
3373
|
// Mark for check since all of these events run outside of change
|
|
3018
3374
|
// detection and we're not guaranteed for something else to have triggered it.
|
|
3019
3375
|
this._changeDetectorRef.markForCheck();
|
|
3020
|
-
});
|
|
3376
|
+
}));
|
|
3021
3377
|
}
|
|
3022
3378
|
}
|
|
3023
3379
|
/**
|
|
@@ -3051,7 +3407,10 @@ CdkDropList.ctorParameters = () => [
|
|
|
3051
3407
|
{ type: CdkDropListGroup, decorators: [{ type: Optional }, { type: SkipSelf }] }
|
|
3052
3408
|
];
|
|
3053
3409
|
CdkDropList.propDecorators = {
|
|
3054
|
-
_draggables: [{ type: ContentChildren, args: [forwardRef((
|
|
3410
|
+
_draggables: [{ type: ContentChildren, args: [forwardRef((/**
|
|
3411
|
+
* @return {?}
|
|
3412
|
+
*/
|
|
3413
|
+
() => CdkDrag)), {
|
|
3055
3414
|
// Explicitly set to false since some of the logic below makes assumptions about it.
|
|
3056
3415
|
// The `.withItems` call below should be updated if we ever need to switch this to `true`.
|
|
3057
3416
|
descendants: false
|
|
@@ -3072,7 +3431,7 @@ CdkDropList.propDecorators = {
|
|
|
3072
3431
|
|
|
3073
3432
|
/**
|
|
3074
3433
|
* @fileoverview added by tsickle
|
|
3075
|
-
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
3434
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
3076
3435
|
*/
|
|
3077
3436
|
class DragDropModule {
|
|
3078
3437
|
}
|
|
@@ -3102,12 +3461,12 @@ DragDropModule.decorators = [
|
|
|
3102
3461
|
|
|
3103
3462
|
/**
|
|
3104
3463
|
* @fileoverview added by tsickle
|
|
3105
|
-
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
3464
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
3106
3465
|
*/
|
|
3107
3466
|
|
|
3108
3467
|
/**
|
|
3109
3468
|
* @fileoverview added by tsickle
|
|
3110
|
-
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
3469
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
3111
3470
|
*/
|
|
3112
3471
|
|
|
3113
3472
|
export { DragDrop, DragRef, DropListRef, CdkDropList, CDK_DROP_LIST, CDK_DROP_LIST_CONTAINER, moveItemInArray, transferArrayItem, copyArrayItem, DragDropModule, DragDropRegistry, CdkDropListGroup, CDK_DRAG_CONFIG_FACTORY, CDK_DRAG_CONFIG, CdkDrag, CdkDragHandle, CdkDragPreview, CdkDragPlaceholder, CDK_DRAG_PARENT as ɵb };
|