@angular/cdk 12.2.0-rc.0 → 12.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/cdk-drag-drop.umd.js +51 -38
- package/bundles/cdk-drag-drop.umd.js.map +1 -1
- package/bundles/cdk-text-field.umd.js +29 -8
- package/bundles/cdk-text-field.umd.js.map +1 -1
- package/bundles/cdk.umd.js +1 -1
- package/bundles/cdk.umd.js.map +1 -1
- package/drag-drop/directives/drag.d.ts +2 -0
- package/drag-drop/index.metadata.json +1 -1
- package/esm2015/drag-drop/directives/drag.js +50 -39
- package/esm2015/overlay/overlay-reference.js +1 -1
- package/esm2015/text-field/autosize.js +29 -9
- package/esm2015/version.js +1 -1
- package/fesm2015/cdk.js +1 -1
- package/fesm2015/cdk.js.map +1 -1
- package/fesm2015/drag-drop.js +49 -38
- package/fesm2015/drag-drop.js.map +1 -1
- package/fesm2015/text-field.js +28 -8
- package/fesm2015/text-field.js.map +1 -1
- package/overlay/overlay-reference.d.ts +9 -1
- package/package.json +1 -1
- package/schematics/ng-add/index.js +1 -1
- package/schematics/ng-add/index.mjs +1 -1
- package/text-field/autosize.d.ts +3 -2
- package/text-field/index.metadata.json +1 -1
package/fesm2015/drag-drop.js
CHANGED
|
@@ -3234,43 +3234,22 @@ class CdkDrag {
|
|
|
3234
3234
|
return this._dragRef.getFreeDragPosition();
|
|
3235
3235
|
}
|
|
3236
3236
|
ngAfterViewInit() {
|
|
3237
|
-
//
|
|
3238
|
-
//
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
this.
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
.
|
|
3251
|
-
.map(handle => handle.element);
|
|
3252
|
-
// Usually handles are only allowed to be a descendant of the drag element, but if
|
|
3253
|
-
// the consumer defined a different drag root, we should allow the drag element
|
|
3254
|
-
// itself to be a handle too.
|
|
3255
|
-
if (this._selfHandle && this.rootElementSelector) {
|
|
3256
|
-
childHandleElements.push(this.element);
|
|
3237
|
+
// Normally this isn't in the zone, but it can cause major performance regressions for apps
|
|
3238
|
+
// using `zone-patch-rxjs` because it'll trigger a change detection when it unsubscribes.
|
|
3239
|
+
this._ngZone.runOutsideAngular(() => {
|
|
3240
|
+
// We need to wait for the zone to stabilize, in order for the reference
|
|
3241
|
+
// element to be in the proper place in the DOM. This is mostly relevant
|
|
3242
|
+
// for draggable elements inside portals since they get stamped out in
|
|
3243
|
+
// their original DOM position and then they get transferred to the portal.
|
|
3244
|
+
this._ngZone.onStable
|
|
3245
|
+
.pipe(take(1), takeUntil(this._destroyed))
|
|
3246
|
+
.subscribe(() => {
|
|
3247
|
+
this._updateRootElement();
|
|
3248
|
+
this._setupHandlesListener();
|
|
3249
|
+
if (this.freeDragPosition) {
|
|
3250
|
+
this._dragRef.setFreeDragPosition(this.freeDragPosition);
|
|
3257
3251
|
}
|
|
3258
|
-
this._dragRef.withHandles(childHandleElements);
|
|
3259
|
-
}),
|
|
3260
|
-
// Listen if the state of any of the handles changes.
|
|
3261
|
-
switchMap((handles) => {
|
|
3262
|
-
return merge(...handles.map(item => {
|
|
3263
|
-
return item._stateChanges.pipe(startWith(item));
|
|
3264
|
-
}));
|
|
3265
|
-
}), takeUntil(this._destroyed)).subscribe(handleInstance => {
|
|
3266
|
-
// Enabled/disable the handle that changed in the DragRef.
|
|
3267
|
-
const dragRef = this._dragRef;
|
|
3268
|
-
const handle = handleInstance.element.nativeElement;
|
|
3269
|
-
handleInstance.disabled ? dragRef.disableHandle(handle) : dragRef.enableHandle(handle);
|
|
3270
3252
|
});
|
|
3271
|
-
if (this.freeDragPosition) {
|
|
3272
|
-
this._dragRef.setFreeDragPosition(this.freeDragPosition);
|
|
3273
|
-
}
|
|
3274
3253
|
});
|
|
3275
3254
|
}
|
|
3276
3255
|
ngOnChanges(changes) {
|
|
@@ -3294,9 +3273,12 @@ class CdkDrag {
|
|
|
3294
3273
|
if (index > -1) {
|
|
3295
3274
|
CdkDrag._dragInstances.splice(index, 1);
|
|
3296
3275
|
}
|
|
3297
|
-
|
|
3298
|
-
this.
|
|
3299
|
-
|
|
3276
|
+
// Unnecessary in most cases, but used to avoid extra change detections with `zone-paths-rxjs`.
|
|
3277
|
+
this._ngZone.runOutsideAngular(() => {
|
|
3278
|
+
this._destroyed.next();
|
|
3279
|
+
this._destroyed.complete();
|
|
3280
|
+
this._dragRef.dispose();
|
|
3281
|
+
});
|
|
3300
3282
|
}
|
|
3301
3283
|
/** Syncs the root element with the `DragRef`. */
|
|
3302
3284
|
_updateRootElement() {
|
|
@@ -3451,6 +3433,35 @@ class CdkDrag {
|
|
|
3451
3433
|
this.previewContainer = previewContainer;
|
|
3452
3434
|
}
|
|
3453
3435
|
}
|
|
3436
|
+
/** Sets up the listener that syncs the handles with the drag ref. */
|
|
3437
|
+
_setupHandlesListener() {
|
|
3438
|
+
// Listen for any newly-added handles.
|
|
3439
|
+
this._handles.changes.pipe(startWith(this._handles),
|
|
3440
|
+
// Sync the new handles with the DragRef.
|
|
3441
|
+
tap((handles) => {
|
|
3442
|
+
const childHandleElements = handles
|
|
3443
|
+
.filter(handle => handle._parentDrag === this)
|
|
3444
|
+
.map(handle => handle.element);
|
|
3445
|
+
// Usually handles are only allowed to be a descendant of the drag element, but if
|
|
3446
|
+
// the consumer defined a different drag root, we should allow the drag element
|
|
3447
|
+
// itself to be a handle too.
|
|
3448
|
+
if (this._selfHandle && this.rootElementSelector) {
|
|
3449
|
+
childHandleElements.push(this.element);
|
|
3450
|
+
}
|
|
3451
|
+
this._dragRef.withHandles(childHandleElements);
|
|
3452
|
+
}),
|
|
3453
|
+
// Listen if the state of any of the handles changes.
|
|
3454
|
+
switchMap((handles) => {
|
|
3455
|
+
return merge(...handles.map(item => {
|
|
3456
|
+
return item._stateChanges.pipe(startWith(item));
|
|
3457
|
+
}));
|
|
3458
|
+
}), takeUntil(this._destroyed)).subscribe(handleInstance => {
|
|
3459
|
+
// Enabled/disable the handle that changed in the DragRef.
|
|
3460
|
+
const dragRef = this._dragRef;
|
|
3461
|
+
const handle = handleInstance.element.nativeElement;
|
|
3462
|
+
handleInstance.disabled ? dragRef.disableHandle(handle) : dragRef.enableHandle(handle);
|
|
3463
|
+
});
|
|
3464
|
+
}
|
|
3454
3465
|
}
|
|
3455
3466
|
CdkDrag._dragInstances = [];
|
|
3456
3467
|
CdkDrag.decorators = [
|