@angular/cdk 12.1.0-rc.0 → 12.1.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/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.
|
|
@@ -2487,7 +2493,9 @@
|
|
|
2487
2493
|
*/
|
|
2488
2494
|
DropListRef.prototype._listenToScrollEvents = function () {
|
|
2489
2495
|
var _this = this;
|
|
2490
|
-
this._viewportScrollSubscription = this._dragDropRegistry
|
|
2496
|
+
this._viewportScrollSubscription = this._dragDropRegistry
|
|
2497
|
+
.scrolled(this._getShadowRoot())
|
|
2498
|
+
.subscribe(function (event) {
|
|
2491
2499
|
if (_this.isDragging()) {
|
|
2492
2500
|
var scrollDifference_1 = _this._parentPositions.handleScroll(event);
|
|
2493
2501
|
if (scrollDifference_1) {
|
|
@@ -2653,13 +2661,6 @@
|
|
|
2653
2661
|
return [verticalScrollDirection, horizontalScrollDirection];
|
|
2654
2662
|
}
|
|
2655
2663
|
|
|
2656
|
-
/**
|
|
2657
|
-
* @license
|
|
2658
|
-
* Copyright Google LLC All Rights Reserved.
|
|
2659
|
-
*
|
|
2660
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
2661
|
-
* found in the LICENSE file at https://angular.io/license
|
|
2662
|
-
*/
|
|
2663
2664
|
/** Event options that can be used to bind an active, capturing event. */
|
|
2664
2665
|
var activeCapturingEventOptions = platform.normalizePassiveListenerOptions({
|
|
2665
2666
|
passive: false,
|
|
@@ -2700,7 +2701,11 @@
|
|
|
2700
2701
|
* while the user is dragging a drag item instance.
|
|
2701
2702
|
*/
|
|
2702
2703
|
this.pointerUp = new rxjs.Subject();
|
|
2703
|
-
/**
|
|
2704
|
+
/**
|
|
2705
|
+
* Emits when the viewport has been scrolled while the user is dragging an item.
|
|
2706
|
+
* @deprecated To be turned into a private member. Use the `scrolled` method instead.
|
|
2707
|
+
* @breaking-change 13.0.0
|
|
2708
|
+
*/
|
|
2704
2709
|
this.scroll = new rxjs.Subject();
|
|
2705
2710
|
/**
|
|
2706
2711
|
* Event listener that will prevent the default browser action while the user is dragging.
|
|
@@ -2823,6 +2828,37 @@
|
|
|
2823
2828
|
DragDropRegistry.prototype.isDragging = function (drag) {
|
|
2824
2829
|
return this._activeDragInstances.indexOf(drag) > -1;
|
|
2825
2830
|
};
|
|
2831
|
+
/**
|
|
2832
|
+
* Gets a stream that will emit when any element on the page is scrolled while an item is being
|
|
2833
|
+
* dragged.
|
|
2834
|
+
* @param shadowRoot Optional shadow root that the current dragging sequence started from.
|
|
2835
|
+
* Top-level listeners won't pick up events coming from the shadow DOM so this parameter can
|
|
2836
|
+
* be used to include an additional top-level listener at the shadow root level.
|
|
2837
|
+
*/
|
|
2838
|
+
DragDropRegistry.prototype.scrolled = function (shadowRoot) {
|
|
2839
|
+
var _this = this;
|
|
2840
|
+
var streams = [this.scroll];
|
|
2841
|
+
if (shadowRoot && shadowRoot !== this._document) {
|
|
2842
|
+
// Note that this is basically the same as `fromEvent` from rjxs, but we do it ourselves,
|
|
2843
|
+
// because we want to guarantee that the event is bound outside of the `NgZone`. With
|
|
2844
|
+
// `fromEvent` it'll only happen if the subscription is outside the `NgZone`.
|
|
2845
|
+
streams.push(new rxjs.Observable(function (observer) {
|
|
2846
|
+
return _this._ngZone.runOutsideAngular(function () {
|
|
2847
|
+
var eventOptions = true;
|
|
2848
|
+
var callback = function (event) {
|
|
2849
|
+
if (_this._activeDragInstances.length) {
|
|
2850
|
+
observer.next(event);
|
|
2851
|
+
}
|
|
2852
|
+
};
|
|
2853
|
+
shadowRoot.addEventListener('scroll', callback, eventOptions);
|
|
2854
|
+
return function () {
|
|
2855
|
+
shadowRoot.removeEventListener('scroll', callback, eventOptions);
|
|
2856
|
+
};
|
|
2857
|
+
});
|
|
2858
|
+
}));
|
|
2859
|
+
}
|
|
2860
|
+
return rxjs.merge.apply(void 0, __spreadArray([], __read(streams)));
|
|
2861
|
+
};
|
|
2826
2862
|
DragDropRegistry.prototype.ngOnDestroy = function () {
|
|
2827
2863
|
var _this = this;
|
|
2828
2864
|
this._dragInstances.forEach(function (instance) { return _this.removeDragItem(instance); });
|