@angular/cdk 18.0.0 → 18.1.0-next.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/esm2022/drag-drop/drag-drop-registry.mjs +22 -18
- package/esm2022/drag-drop/drag-ref.mjs +16 -14
- package/esm2022/listbox/listbox.mjs +7 -6
- package/esm2022/version.mjs +1 -1
- package/fesm2022/cdk.mjs +1 -1
- package/fesm2022/cdk.mjs.map +1 -1
- package/fesm2022/drag-drop.mjs +162 -157
- package/fesm2022/drag-drop.mjs.map +1 -1
- package/fesm2022/listbox.mjs +7 -6
- package/fesm2022/listbox.mjs.map +1 -1
- package/package.json +3 -3
- package/schematics/ng-add/index.js +1 -1
- package/schematics/ng-add/index.mjs +1 -1
package/fesm2022/drag-drop.mjs
CHANGED
|
@@ -1,95 +1,71 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Component, ViewEncapsulation, ChangeDetectionStrategy, inject, ApplicationRef, EnvironmentInjector, createComponent, Injectable, Inject, InjectionToken, booleanAttribute, Directive, Optional, SkipSelf, Input, EventEmitter, Injector, afterNextRender, Self, Output, NgModule } from '@angular/core';
|
|
2
|
+
import { signal, Component, ViewEncapsulation, ChangeDetectionStrategy, inject, ApplicationRef, EnvironmentInjector, createComponent, Injectable, Inject, InjectionToken, booleanAttribute, Directive, Optional, SkipSelf, Input, EventEmitter, Injector, afterNextRender, Self, Output, NgModule } from '@angular/core';
|
|
3
3
|
import { DOCUMENT } from '@angular/common';
|
|
4
4
|
import * as i1 from '@angular/cdk/scrolling';
|
|
5
5
|
import { CdkScrollableModule } from '@angular/cdk/scrolling';
|
|
6
|
-
import { _getEventTarget, normalizePassiveListenerOptions, _getShadowRoot } from '@angular/cdk/platform';
|
|
7
|
-
import { coerceElement, coerceNumberProperty, coerceArray } from '@angular/cdk/coercion';
|
|
8
6
|
import { isFakeTouchstartFromScreenReader, isFakeMousedownFromScreenReader } from '@angular/cdk/a11y';
|
|
7
|
+
import { coerceElement, coerceNumberProperty, coerceArray } from '@angular/cdk/coercion';
|
|
8
|
+
import { _getEventTarget, normalizePassiveListenerOptions, _getShadowRoot } from '@angular/cdk/platform';
|
|
9
9
|
import { Subject, Subscription, interval, animationFrameScheduler, Observable, merge, BehaviorSubject } from 'rxjs';
|
|
10
10
|
import { takeUntil, map, take, tap, switchMap, startWith } from 'rxjs/operators';
|
|
11
11
|
import * as i1$1 from '@angular/cdk/bidi';
|
|
12
12
|
|
|
13
|
-
/**
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (value) {
|
|
23
|
-
dest.setProperty(key, value, importantProperties?.has(key) ? 'important' : '');
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
dest.removeProperty(key);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
13
|
+
/** Creates a deep clone of an element. */
|
|
14
|
+
function deepCloneNode(node) {
|
|
15
|
+
const clone = node.cloneNode(true);
|
|
16
|
+
const descendantsWithId = clone.querySelectorAll('[id]');
|
|
17
|
+
const nodeName = node.nodeName.toLowerCase();
|
|
18
|
+
// Remove the `id` to avoid having multiple elements with the same id on the page.
|
|
19
|
+
clone.removeAttribute('id');
|
|
20
|
+
for (let i = 0; i < descendantsWithId.length; i++) {
|
|
21
|
+
descendantsWithId[i].removeAttribute('id');
|
|
29
22
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const userSelect = enable ? '' : 'none';
|
|
40
|
-
extendStyles(element.style, {
|
|
41
|
-
'touch-action': enable ? '' : 'none',
|
|
42
|
-
'-webkit-user-drag': enable ? '' : 'none',
|
|
43
|
-
'-webkit-tap-highlight-color': enable ? '' : 'transparent',
|
|
44
|
-
'user-select': userSelect,
|
|
45
|
-
'-ms-user-select': userSelect,
|
|
46
|
-
'-webkit-user-select': userSelect,
|
|
47
|
-
'-moz-user-select': userSelect,
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Toggles whether an element is visible while preserving its dimensions.
|
|
52
|
-
* @param element Element whose visibility to toggle
|
|
53
|
-
* @param enable Whether the element should be visible.
|
|
54
|
-
* @param importantProperties Properties to be set as `!important`.
|
|
55
|
-
* @docs-private
|
|
56
|
-
*/
|
|
57
|
-
function toggleVisibility(element, enable, importantProperties) {
|
|
58
|
-
extendStyles(element.style, {
|
|
59
|
-
position: enable ? '' : 'fixed',
|
|
60
|
-
top: enable ? '' : '0',
|
|
61
|
-
opacity: enable ? '' : '0',
|
|
62
|
-
left: enable ? '' : '-999em',
|
|
63
|
-
}, importantProperties);
|
|
23
|
+
if (nodeName === 'canvas') {
|
|
24
|
+
transferCanvasData(node, clone);
|
|
25
|
+
}
|
|
26
|
+
else if (nodeName === 'input' || nodeName === 'select' || nodeName === 'textarea') {
|
|
27
|
+
transferInputData(node, clone);
|
|
28
|
+
}
|
|
29
|
+
transferData('canvas', node, clone, transferCanvasData);
|
|
30
|
+
transferData('input, textarea, select', node, clone, transferInputData);
|
|
31
|
+
return clone;
|
|
64
32
|
}
|
|
65
|
-
/**
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
33
|
+
/** Matches elements between an element and its clone and allows for their data to be cloned. */
|
|
34
|
+
function transferData(selector, node, clone, callback) {
|
|
35
|
+
const descendantElements = node.querySelectorAll(selector);
|
|
36
|
+
if (descendantElements.length) {
|
|
37
|
+
const cloneElements = clone.querySelectorAll(selector);
|
|
38
|
+
for (let i = 0; i < descendantElements.length; i++) {
|
|
39
|
+
callback(descendantElements[i], cloneElements[i]);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
73
42
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
43
|
+
// Counter for unique cloned radio button names.
|
|
44
|
+
let cloneUniqueId = 0;
|
|
45
|
+
/** Transfers the data of one input element to another. */
|
|
46
|
+
function transferInputData(source, clone) {
|
|
47
|
+
// Browsers throw an error when assigning the value of a file input programmatically.
|
|
48
|
+
if (clone.type !== 'file') {
|
|
49
|
+
clone.value = source.value;
|
|
50
|
+
}
|
|
51
|
+
// Radio button `name` attributes must be unique for radio button groups
|
|
52
|
+
// otherwise original radio buttons can lose their checked state
|
|
53
|
+
// once the clone is inserted in the DOM.
|
|
54
|
+
if (clone.type === 'radio' && clone.name) {
|
|
55
|
+
clone.name = `mat-clone-${clone.name}-${cloneUniqueId++}`;
|
|
56
|
+
}
|
|
83
57
|
}
|
|
84
|
-
/**
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
58
|
+
/** Transfers the data of one canvas element to another. */
|
|
59
|
+
function transferCanvasData(source, clone) {
|
|
60
|
+
const context = clone.getContext('2d');
|
|
61
|
+
if (context) {
|
|
62
|
+
// In some cases `drawImage` can throw (e.g. if the canvas size is 0x0).
|
|
63
|
+
// We can't do much about it so just ignore the error.
|
|
64
|
+
try {
|
|
65
|
+
context.drawImage(source, 0, 0);
|
|
66
|
+
}
|
|
67
|
+
catch { }
|
|
68
|
+
}
|
|
93
69
|
}
|
|
94
70
|
|
|
95
71
|
/** Gets a mutable version of an element's bounding `DOMRect`. */
|
|
@@ -216,64 +192,6 @@ class ParentPositionTracker {
|
|
|
216
192
|
}
|
|
217
193
|
}
|
|
218
194
|
|
|
219
|
-
/** Creates a deep clone of an element. */
|
|
220
|
-
function deepCloneNode(node) {
|
|
221
|
-
const clone = node.cloneNode(true);
|
|
222
|
-
const descendantsWithId = clone.querySelectorAll('[id]');
|
|
223
|
-
const nodeName = node.nodeName.toLowerCase();
|
|
224
|
-
// Remove the `id` to avoid having multiple elements with the same id on the page.
|
|
225
|
-
clone.removeAttribute('id');
|
|
226
|
-
for (let i = 0; i < descendantsWithId.length; i++) {
|
|
227
|
-
descendantsWithId[i].removeAttribute('id');
|
|
228
|
-
}
|
|
229
|
-
if (nodeName === 'canvas') {
|
|
230
|
-
transferCanvasData(node, clone);
|
|
231
|
-
}
|
|
232
|
-
else if (nodeName === 'input' || nodeName === 'select' || nodeName === 'textarea') {
|
|
233
|
-
transferInputData(node, clone);
|
|
234
|
-
}
|
|
235
|
-
transferData('canvas', node, clone, transferCanvasData);
|
|
236
|
-
transferData('input, textarea, select', node, clone, transferInputData);
|
|
237
|
-
return clone;
|
|
238
|
-
}
|
|
239
|
-
/** Matches elements between an element and its clone and allows for their data to be cloned. */
|
|
240
|
-
function transferData(selector, node, clone, callback) {
|
|
241
|
-
const descendantElements = node.querySelectorAll(selector);
|
|
242
|
-
if (descendantElements.length) {
|
|
243
|
-
const cloneElements = clone.querySelectorAll(selector);
|
|
244
|
-
for (let i = 0; i < descendantElements.length; i++) {
|
|
245
|
-
callback(descendantElements[i], cloneElements[i]);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
// Counter for unique cloned radio button names.
|
|
250
|
-
let cloneUniqueId = 0;
|
|
251
|
-
/** Transfers the data of one input element to another. */
|
|
252
|
-
function transferInputData(source, clone) {
|
|
253
|
-
// Browsers throw an error when assigning the value of a file input programmatically.
|
|
254
|
-
if (clone.type !== 'file') {
|
|
255
|
-
clone.value = source.value;
|
|
256
|
-
}
|
|
257
|
-
// Radio button `name` attributes must be unique for radio button groups
|
|
258
|
-
// otherwise original radio buttons can lose their checked state
|
|
259
|
-
// once the clone is inserted in the DOM.
|
|
260
|
-
if (clone.type === 'radio' && clone.name) {
|
|
261
|
-
clone.name = `mat-clone-${clone.name}-${cloneUniqueId++}`;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
/** Transfers the data of one canvas element to another. */
|
|
265
|
-
function transferCanvasData(source, clone) {
|
|
266
|
-
const context = clone.getContext('2d');
|
|
267
|
-
if (context) {
|
|
268
|
-
// In some cases `drawImage` can throw (e.g. if the canvas size is 0x0).
|
|
269
|
-
// We can't do much about it so just ignore the error.
|
|
270
|
-
try {
|
|
271
|
-
context.drawImage(source, 0, 0);
|
|
272
|
-
}
|
|
273
|
-
catch { }
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
|
|
277
195
|
/**
|
|
278
196
|
* Gets the root HTML element of an embedded view.
|
|
279
197
|
* If the root is not an HTML element it gets wrapped in one.
|
|
@@ -288,6 +206,88 @@ function getRootNode(viewRef, _document) {
|
|
|
288
206
|
return wrapper;
|
|
289
207
|
}
|
|
290
208
|
|
|
209
|
+
/**
|
|
210
|
+
* Shallow-extends a stylesheet object with another stylesheet-like object.
|
|
211
|
+
* Note that the keys in `source` have to be dash-cased.
|
|
212
|
+
* @docs-private
|
|
213
|
+
*/
|
|
214
|
+
function extendStyles(dest, source, importantProperties) {
|
|
215
|
+
for (let key in source) {
|
|
216
|
+
if (source.hasOwnProperty(key)) {
|
|
217
|
+
const value = source[key];
|
|
218
|
+
if (value) {
|
|
219
|
+
dest.setProperty(key, value, importantProperties?.has(key) ? 'important' : '');
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
dest.removeProperty(key);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return dest;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Toggles whether the native drag interactions should be enabled for an element.
|
|
230
|
+
* @param element Element on which to toggle the drag interactions.
|
|
231
|
+
* @param enable Whether the drag interactions should be enabled.
|
|
232
|
+
* @docs-private
|
|
233
|
+
*/
|
|
234
|
+
function toggleNativeDragInteractions(element, enable) {
|
|
235
|
+
const userSelect = enable ? '' : 'none';
|
|
236
|
+
extendStyles(element.style, {
|
|
237
|
+
'touch-action': enable ? '' : 'none',
|
|
238
|
+
'-webkit-user-drag': enable ? '' : 'none',
|
|
239
|
+
'-webkit-tap-highlight-color': enable ? '' : 'transparent',
|
|
240
|
+
'user-select': userSelect,
|
|
241
|
+
'-ms-user-select': userSelect,
|
|
242
|
+
'-webkit-user-select': userSelect,
|
|
243
|
+
'-moz-user-select': userSelect,
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Toggles whether an element is visible while preserving its dimensions.
|
|
248
|
+
* @param element Element whose visibility to toggle
|
|
249
|
+
* @param enable Whether the element should be visible.
|
|
250
|
+
* @param importantProperties Properties to be set as `!important`.
|
|
251
|
+
* @docs-private
|
|
252
|
+
*/
|
|
253
|
+
function toggleVisibility(element, enable, importantProperties) {
|
|
254
|
+
extendStyles(element.style, {
|
|
255
|
+
position: enable ? '' : 'fixed',
|
|
256
|
+
top: enable ? '' : '0',
|
|
257
|
+
opacity: enable ? '' : '0',
|
|
258
|
+
left: enable ? '' : '-999em',
|
|
259
|
+
}, importantProperties);
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Combines a transform string with an optional other transform
|
|
263
|
+
* that exited before the base transform was applied.
|
|
264
|
+
*/
|
|
265
|
+
function combineTransforms(transform, initialTransform) {
|
|
266
|
+
return initialTransform && initialTransform != 'none'
|
|
267
|
+
? transform + ' ' + initialTransform
|
|
268
|
+
: transform;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Matches the target element's size to the source's size.
|
|
272
|
+
* @param target Element that needs to be resized.
|
|
273
|
+
* @param sourceRect Dimensions of the source element.
|
|
274
|
+
*/
|
|
275
|
+
function matchElementSize(target, sourceRect) {
|
|
276
|
+
target.style.width = `${sourceRect.width}px`;
|
|
277
|
+
target.style.height = `${sourceRect.height}px`;
|
|
278
|
+
target.style.transform = getTransform(sourceRect.left, sourceRect.top);
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Gets a 3d `transform` that can be applied to an element.
|
|
282
|
+
* @param x Desired position of the element along the X axis.
|
|
283
|
+
* @param y Desired position of the element along the Y axis.
|
|
284
|
+
*/
|
|
285
|
+
function getTransform(x, y) {
|
|
286
|
+
// Round the transforms since some browsers will
|
|
287
|
+
// blur the elements for sub-pixel transforms.
|
|
288
|
+
return `translate3d(${Math.round(x)}px, ${Math.round(y)}px, 0)`;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
291
|
/** Parses a CSS time value to milliseconds. */
|
|
292
292
|
function parseCssTimeUnitsToMs(value) {
|
|
293
293
|
// Some browsers will return it in seconds, whereas others will return milliseconds.
|
|
@@ -475,7 +475,7 @@ class DragRef {
|
|
|
475
475
|
* Whether the dragging sequence has been started. Doesn't
|
|
476
476
|
* necessarily mean that the element has been moved.
|
|
477
477
|
*/
|
|
478
|
-
this._hasStartedDragging = false;
|
|
478
|
+
this._hasStartedDragging = signal(false);
|
|
479
479
|
/** Emits when the item is being moved. */
|
|
480
480
|
this._moveEvents = new Subject();
|
|
481
481
|
/** Subscription to pointer movement events. */
|
|
@@ -538,7 +538,7 @@ class DragRef {
|
|
|
538
538
|
/** Handler that is invoked when the user moves their pointer after they've initiated a drag. */
|
|
539
539
|
this._pointerMove = (event) => {
|
|
540
540
|
const pointerPosition = this._getPointerPositionOnPage(event);
|
|
541
|
-
if (!this._hasStartedDragging) {
|
|
541
|
+
if (!this._hasStartedDragging()) {
|
|
542
542
|
const distanceX = Math.abs(pointerPosition.x - this._pickupPositionOnPage.x);
|
|
543
543
|
const distanceY = Math.abs(pointerPosition.y - this._pickupPositionOnPage.y);
|
|
544
544
|
const isOverThreshold = distanceX + distanceY >= this._config.dragStartThreshold;
|
|
@@ -562,7 +562,7 @@ class DragRef {
|
|
|
562
562
|
if (event.cancelable) {
|
|
563
563
|
event.preventDefault();
|
|
564
564
|
}
|
|
565
|
-
this._hasStartedDragging
|
|
565
|
+
this._hasStartedDragging.set(true);
|
|
566
566
|
this._ngZone.run(() => this._startDragSequence(event));
|
|
567
567
|
}
|
|
568
568
|
}
|
|
@@ -760,7 +760,7 @@ class DragRef {
|
|
|
760
760
|
}
|
|
761
761
|
/** Checks whether the element is currently being dragged. */
|
|
762
762
|
isDragging() {
|
|
763
|
-
return this._hasStartedDragging && this._dragDropRegistry.isDragging(this);
|
|
763
|
+
return this._hasStartedDragging() && this._dragDropRegistry.isDragging(this);
|
|
764
764
|
}
|
|
765
765
|
/** Resets a standalone drag item to its initial position. */
|
|
766
766
|
reset() {
|
|
@@ -869,7 +869,7 @@ class DragRef {
|
|
|
869
869
|
this._rootElement.style.webkitTapHighlightColor =
|
|
870
870
|
this._rootElementTapHighlight;
|
|
871
871
|
}
|
|
872
|
-
if (!this._hasStartedDragging) {
|
|
872
|
+
if (!this._hasStartedDragging()) {
|
|
873
873
|
return;
|
|
874
874
|
}
|
|
875
875
|
this.released.next({ source: this, event });
|
|
@@ -993,7 +993,8 @@ class DragRef {
|
|
|
993
993
|
this._rootElementTapHighlight = rootStyles.webkitTapHighlightColor || '';
|
|
994
994
|
rootStyles.webkitTapHighlightColor = 'transparent';
|
|
995
995
|
}
|
|
996
|
-
this.
|
|
996
|
+
this._hasMoved = false;
|
|
997
|
+
this._hasStartedDragging.set(this._hasMoved);
|
|
997
998
|
// Avoid multiple subscriptions and memory leaks when multi touch
|
|
998
999
|
// (isDragging check above isn't enough because of possible temporal and/or dimensional delays)
|
|
999
1000
|
this._removeListeners();
|
|
@@ -2512,7 +2513,7 @@ class DragDropRegistry {
|
|
|
2512
2513
|
/** Registered drag item instances. */
|
|
2513
2514
|
this._dragInstances = new Set();
|
|
2514
2515
|
/** Drag item instances that are currently being dragged. */
|
|
2515
|
-
this._activeDragInstances = [];
|
|
2516
|
+
this._activeDragInstances = signal([]);
|
|
2516
2517
|
/** Keeps track of the event listeners that we've bound to the `document`. */
|
|
2517
2518
|
this._globalListeners = new Map();
|
|
2518
2519
|
/**
|
|
@@ -2541,17 +2542,17 @@ class DragDropRegistry {
|
|
|
2541
2542
|
* @param event Event whose default action should be prevented.
|
|
2542
2543
|
*/
|
|
2543
2544
|
this._preventDefaultWhileDragging = (event) => {
|
|
2544
|
-
if (this._activeDragInstances.length > 0) {
|
|
2545
|
+
if (this._activeDragInstances().length > 0) {
|
|
2545
2546
|
event.preventDefault();
|
|
2546
2547
|
}
|
|
2547
2548
|
};
|
|
2548
2549
|
/** Event listener for `touchmove` that is bound even if no dragging is happening. */
|
|
2549
2550
|
this._persistentTouchmoveListener = (event) => {
|
|
2550
|
-
if (this._activeDragInstances.length > 0) {
|
|
2551
|
+
if (this._activeDragInstances().length > 0) {
|
|
2551
2552
|
// Note that we only want to prevent the default action after dragging has actually started.
|
|
2552
2553
|
// Usually this is the same time at which the item is added to the `_activeDragInstances`,
|
|
2553
2554
|
// but it could be pushed back if the user has set up a drag delay or threshold.
|
|
2554
|
-
if (this._activeDragInstances.some(this._draggingPredicate)) {
|
|
2555
|
+
if (this._activeDragInstances().some(this._draggingPredicate)) {
|
|
2555
2556
|
event.preventDefault();
|
|
2556
2557
|
}
|
|
2557
2558
|
this.pointerMove.next(event);
|
|
@@ -2598,12 +2599,12 @@ class DragDropRegistry {
|
|
|
2598
2599
|
*/
|
|
2599
2600
|
startDragging(drag, event) {
|
|
2600
2601
|
// Do not process the same drag twice to avoid memory leaks and redundant listeners
|
|
2601
|
-
if (this._activeDragInstances.indexOf(drag) > -1) {
|
|
2602
|
+
if (this._activeDragInstances().indexOf(drag) > -1) {
|
|
2602
2603
|
return;
|
|
2603
2604
|
}
|
|
2604
2605
|
this._loadResets();
|
|
2605
|
-
this._activeDragInstances.
|
|
2606
|
-
if (this._activeDragInstances.length === 1) {
|
|
2606
|
+
this._activeDragInstances.update(instances => [...instances, drag]);
|
|
2607
|
+
if (this._activeDragInstances().length === 1) {
|
|
2607
2608
|
const isTouchEvent = event.type.startsWith('touch');
|
|
2608
2609
|
// We explicitly bind __active__ listeners here, because newer browsers will default to
|
|
2609
2610
|
// passive ones for `mousemove` and `touchmove`. The events need to be active, because we
|
|
@@ -2644,17 +2645,21 @@ class DragDropRegistry {
|
|
|
2644
2645
|
}
|
|
2645
2646
|
/** Stops dragging a drag item instance. */
|
|
2646
2647
|
stopDragging(drag) {
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2648
|
+
this._activeDragInstances.update(instances => {
|
|
2649
|
+
const index = instances.indexOf(drag);
|
|
2650
|
+
if (index > -1) {
|
|
2651
|
+
instances.splice(index, 1);
|
|
2652
|
+
return [...instances];
|
|
2652
2653
|
}
|
|
2654
|
+
return instances;
|
|
2655
|
+
});
|
|
2656
|
+
if (this._activeDragInstances().length === 0) {
|
|
2657
|
+
this._clearGlobalListeners();
|
|
2653
2658
|
}
|
|
2654
2659
|
}
|
|
2655
2660
|
/** Gets whether a drag item instance is currently being dragged. */
|
|
2656
2661
|
isDragging(drag) {
|
|
2657
|
-
return this._activeDragInstances.indexOf(drag) > -1;
|
|
2662
|
+
return this._activeDragInstances().indexOf(drag) > -1;
|
|
2658
2663
|
}
|
|
2659
2664
|
/**
|
|
2660
2665
|
* Gets a stream that will emit when any element on the page is scrolled while an item is being
|
|
@@ -2673,7 +2678,7 @@ class DragDropRegistry {
|
|
|
2673
2678
|
return this._ngZone.runOutsideAngular(() => {
|
|
2674
2679
|
const eventOptions = true;
|
|
2675
2680
|
const callback = (event) => {
|
|
2676
|
-
if (this._activeDragInstances.length) {
|
|
2681
|
+
if (this._activeDragInstances().length) {
|
|
2677
2682
|
observer.next(event);
|
|
2678
2683
|
}
|
|
2679
2684
|
};
|