@angular/cdk 12.0.5 → 12.0.6
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/bundles/cdk-drag-drop.umd.js +53 -17
- package/bundles/cdk-drag-drop.umd.js.map +1 -1
- package/bundles/cdk.umd.js +1 -1
- package/bundles/cdk.umd.js.map +1 -1
- package/drag-drop/drag-drop-registry.d.ts +14 -2
- package/drag-drop/index.metadata.json +1 -1
- package/drag-drop/parent-position-tracker.d.ts +2 -0
- package/esm2015/drag-drop/drag-drop-registry.js +37 -3
- package/esm2015/drag-drop/drag-ref.js +11 -9
- package/esm2015/drag-drop/drop-list-ref.js +4 -2
- package/esm2015/drag-drop/parent-position-tracker.js +6 -2
- package/esm2015/version.js +1 -1
- package/fesm2015/cdk.js +1 -1
- package/fesm2015/cdk.js.map +1 -1
- package/fesm2015/drag-drop.js +52 -10
- package/fesm2015/drag-drop.js.map +1 -1
- package/package.json +1 -1
- package/schematics/ng-add/index.js +1 -1
- package/schematics/ng-add/index.mjs +1 -1
|
@@ -216,7 +216,7 @@
|
|
|
216
216
|
};
|
|
217
217
|
/** Handles scrolling while a drag is taking place. */
|
|
218
218
|
ParentPositionTracker.prototype.handleScroll = function (event) {
|
|
219
|
-
var target = event
|
|
219
|
+
var target = getEventTarget(event);
|
|
220
220
|
var cachedPosition = this.positions.get(target);
|
|
221
221
|
if (!cachedPosition) {
|
|
222
222
|
return null;
|
|
@@ -252,6 +252,10 @@
|
|
|
252
252
|
};
|
|
253
253
|
return ParentPositionTracker;
|
|
254
254
|
}());
|
|
255
|
+
/** Gets the target of an event while accounting for shadow dom. */
|
|
256
|
+
function getEventTarget(event) {
|
|
257
|
+
return (event.composedPath ? event.composedPath()[0] : event.target);
|
|
258
|
+
}
|
|
255
259
|
|
|
256
260
|
/**
|
|
257
261
|
* @license
|
|
@@ -412,7 +416,7 @@
|
|
|
412
416
|
// Delegate the event based on whether it started from a handle or the element itself.
|
|
413
417
|
if (_this._handles.length) {
|
|
414
418
|
var targetHandle = _this._handles.find(function (handle) {
|
|
415
|
-
var target = event
|
|
419
|
+
var target = getEventTarget(event);
|
|
416
420
|
return !!target && (target === handle || handle.contains(target));
|
|
417
421
|
});
|
|
418
422
|
if (targetHandle && !_this._disabledHandles.has(targetHandle) && !_this.disabled) {
|
|
@@ -860,6 +864,7 @@
|
|
|
860
864
|
var isTouchSequence = isTouchEvent(event);
|
|
861
865
|
var isAuxiliaryMouseButton = !isTouchSequence && event.button !== 0;
|
|
862
866
|
var rootElement = this._rootElement;
|
|
867
|
+
var target = getEventTarget(event);
|
|
863
868
|
var isSyntheticEvent = !isTouchSequence && this._lastTouchEventTime &&
|
|
864
869
|
this._lastTouchEventTime + MOUSE_EVENT_IGNORE_TIME > Date.now();
|
|
865
870
|
// If the event started from an element with the native HTML drag&drop, it'll interfere
|
|
@@ -868,7 +873,7 @@
|
|
|
868
873
|
// it's flaky and it fails if the user drags it away quickly. Also note that we only want
|
|
869
874
|
// to do this for `mousedown` since doing the same for `touchstart` will stop any `click`
|
|
870
875
|
// events from firing on touch devices.
|
|
871
|
-
if (
|
|
876
|
+
if (target && target.draggable && event.type === 'mousedown') {
|
|
872
877
|
event.preventDefault();
|
|
873
878
|
}
|
|
874
879
|
// Abort if the user is already dragging or is using a mouse button other than the primary one.
|
|
@@ -888,9 +893,9 @@
|
|
|
888
893
|
this._removeSubscriptions();
|
|
889
894
|
this._pointerMoveSubscription = this._dragDropRegistry.pointerMove.subscribe(this._pointerMove);
|
|
890
895
|
this._pointerUpSubscription = this._dragDropRegistry.pointerUp.subscribe(this._pointerUp);
|
|
891
|
-
this._scrollSubscription = this._dragDropRegistry
|
|
892
|
-
|
|
893
|
-
|
|
896
|
+
this._scrollSubscription = this._dragDropRegistry
|
|
897
|
+
.scrolled(this._getShadowRoot())
|
|
898
|
+
.subscribe(function (scrollEvent) { return _this._updateOnScroll(scrollEvent); });
|
|
894
899
|
if (this._boundaryElement) {
|
|
895
900
|
this._boundaryRect = getMutableClientRect(this._boundaryElement);
|
|
896
901
|
}
|
|
@@ -1068,7 +1073,8 @@
|
|
|
1068
1073
|
return this._ngZone.runOutsideAngular(function () {
|
|
1069
1074
|
return new Promise(function (resolve) {
|
|
1070
1075
|
var handler = (function (event) {
|
|
1071
|
-
if (!event || (event
|
|
1076
|
+
if (!event || (getEventTarget(event) === _this._preview &&
|
|
1077
|
+
event.propertyName === 'transform')) {
|
|
1072
1078
|
_this._preview.removeEventListener('transitionend', handler);
|
|
1073
1079
|
resolve();
|
|
1074
1080
|
clearTimeout(timeout);
|
|
@@ -1316,7 +1322,7 @@
|
|
|
1316
1322
|
DragRef.prototype._updateOnScroll = function (event) {
|
|
1317
1323
|
var scrollDifference = this._parentPositions.handleScroll(event);
|
|
1318
1324
|
if (scrollDifference) {
|
|
1319
|
-
var target = event
|
|
1325
|
+
var target = getEventTarget(event);
|
|
1320
1326
|
// ClientRect dimensions are based on the scroll position of the page and its parent node so
|
|
1321
1327
|
// we have to update the cached boundary ClientRect if the user has scrolled. Check for
|
|
1322
1328
|
// the `document` specifically since IE doesn't support `contains` on it.
|
|
@@ -2484,7 +2490,9 @@
|
|
|
2484
2490
|
*/
|
|
2485
2491
|
DropListRef.prototype._listenToScrollEvents = function () {
|
|
2486
2492
|
var _this = this;
|
|
2487
|
-
this._viewportScrollSubscription = this._dragDropRegistry
|
|
2493
|
+
this._viewportScrollSubscription = this._dragDropRegistry
|
|
2494
|
+
.scrolled(this._getShadowRoot())
|
|
2495
|
+
.subscribe(function (event) {
|
|
2488
2496
|
if (_this.isDragging()) {
|
|
2489
2497
|
var scrollDifference_1 = _this._parentPositions.handleScroll(event);
|
|
2490
2498
|
if (scrollDifference_1) {
|
|
@@ -2650,13 +2658,6 @@
|
|
|
2650
2658
|
return [verticalScrollDirection, horizontalScrollDirection];
|
|
2651
2659
|
}
|
|
2652
2660
|
|
|
2653
|
-
/**
|
|
2654
|
-
* @license
|
|
2655
|
-
* Copyright Google LLC All Rights Reserved.
|
|
2656
|
-
*
|
|
2657
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
2658
|
-
* found in the LICENSE file at https://angular.io/license
|
|
2659
|
-
*/
|
|
2660
2661
|
/** Event options that can be used to bind an active, capturing event. */
|
|
2661
2662
|
var activeCapturingEventOptions = platform.normalizePassiveListenerOptions({
|
|
2662
2663
|
passive: false,
|
|
@@ -2697,7 +2698,11 @@
|
|
|
2697
2698
|
* while the user is dragging a drag item instance.
|
|
2698
2699
|
*/
|
|
2699
2700
|
this.pointerUp = new rxjs.Subject();
|
|
2700
|
-
/**
|
|
2701
|
+
/**
|
|
2702
|
+
* Emits when the viewport has been scrolled while the user is dragging an item.
|
|
2703
|
+
* @deprecated To be turned into a private member. Use the `scrolled` method instead.
|
|
2704
|
+
* @breaking-change 13.0.0
|
|
2705
|
+
*/
|
|
2701
2706
|
this.scroll = new rxjs.Subject();
|
|
2702
2707
|
/**
|
|
2703
2708
|
* Event listener that will prevent the default browser action while the user is dragging.
|
|
@@ -2820,6 +2825,37 @@
|
|
|
2820
2825
|
DragDropRegistry.prototype.isDragging = function (drag) {
|
|
2821
2826
|
return this._activeDragInstances.indexOf(drag) > -1;
|
|
2822
2827
|
};
|
|
2828
|
+
/**
|
|
2829
|
+
* Gets a stream that will emit when any element on the page is scrolled while an item is being
|
|
2830
|
+
* dragged.
|
|
2831
|
+
* @param shadowRoot Optional shadow root that the current dragging sequence started from.
|
|
2832
|
+
* Top-level listeners won't pick up events coming from the shadow DOM so this parameter can
|
|
2833
|
+
* be used to include an additional top-level listener at the shadow root level.
|
|
2834
|
+
*/
|
|
2835
|
+
DragDropRegistry.prototype.scrolled = function (shadowRoot) {
|
|
2836
|
+
var _this = this;
|
|
2837
|
+
var streams = [this.scroll];
|
|
2838
|
+
if (shadowRoot && shadowRoot !== this._document) {
|
|
2839
|
+
// Note that this is basically the same as `fromEvent` from rjxs, but we do it ourselves,
|
|
2840
|
+
// because we want to guarantee that the event is bound outside of the `NgZone`. With
|
|
2841
|
+
// `fromEvent` it'll only happen if the subscription is outside the `NgZone`.
|
|
2842
|
+
streams.push(new rxjs.Observable(function (observer) {
|
|
2843
|
+
return _this._ngZone.runOutsideAngular(function () {
|
|
2844
|
+
var eventOptions = true;
|
|
2845
|
+
var callback = function (event) {
|
|
2846
|
+
if (_this._activeDragInstances.length) {
|
|
2847
|
+
observer.next(event);
|
|
2848
|
+
}
|
|
2849
|
+
};
|
|
2850
|
+
shadowRoot.addEventListener('scroll', callback, eventOptions);
|
|
2851
|
+
return function () {
|
|
2852
|
+
shadowRoot.removeEventListener('scroll', callback, eventOptions);
|
|
2853
|
+
};
|
|
2854
|
+
});
|
|
2855
|
+
}));
|
|
2856
|
+
}
|
|
2857
|
+
return rxjs.merge.apply(void 0, __spreadArray([], __read(streams)));
|
|
2858
|
+
};
|
|
2823
2859
|
DragDropRegistry.prototype.ngOnDestroy = function () {
|
|
2824
2860
|
var _this = this;
|
|
2825
2861
|
this._dragInstances.forEach(function (instance) { return _this.removeDragItem(instance); });
|