@angular/cdk 8.1.4 → 8.2.3
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/a11y/typings/index.metadata.json +1 -1
- package/a11y/typings/key-manager/focus-key-manager.d.ts +1 -1
- package/bundles/cdk-a11y.umd.js +10 -2
- 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-drag-drop.umd.js +239 -36
- 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-overlay.umd.js +15 -8
- 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 +21 -0
- 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-scrolling.umd.js +1 -1
- package/bundles/cdk-scrolling.umd.js.map +1 -1
- package/bundles/cdk-scrolling.umd.min.js.map +1 -1
- package/bundles/cdk-stepper.umd.js +46 -40
- package/bundles/cdk-stepper.umd.js.map +1 -1
- package/bundles/cdk-stepper.umd.min.js +1 -1
- package/bundles/cdk-stepper.umd.min.js.map +1 -1
- package/bundles/cdk-table.umd.js +4 -4
- package/bundles/cdk-table.umd.js.map +1 -1
- package/bundles/cdk-table.umd.min.js.map +1 -1
- package/bundles/cdk-testing.umd.js +404 -0
- package/bundles/cdk-testing.umd.js.map +1 -0
- package/bundles/cdk-testing.umd.min.js +9 -0
- package/bundles/cdk-testing.umd.min.js.map +1 -0
- package/bundles/cdk-text-field.umd.js +3 -3
- package/bundles/cdk-text-field.umd.js.map +1 -1
- package/bundles/cdk-text-field.umd.min.js.map +1 -1
- package/bundles/cdk.umd.js +1 -1
- 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/drag-ref.d.ts +9 -0
- package/drag-drop/typings/drop-list-ref.d.ts +7 -1
- package/drag-drop/typings/index.metadata.json +1 -1
- package/esm2015/a11y.js +10 -2
- package/esm2015/a11y.js.map +1 -1
- package/esm2015/cdk.js +1 -1
- package/esm2015/cdk.js.map +1 -1
- package/esm2015/drag-drop.js +212 -37
- package/esm2015/drag-drop.js.map +1 -1
- package/esm2015/overlay.js +13 -6
- package/esm2015/overlay.js.map +1 -1
- package/esm2015/platform.js +21 -1
- package/esm2015/platform.js.map +1 -1
- package/esm2015/scrolling.js +1 -1
- package/esm2015/scrolling.js.map +1 -1
- package/esm2015/stepper.js +51 -45
- package/esm2015/stepper.js.map +1 -1
- package/esm2015/table.js +4 -4
- package/esm2015/table.js.map +1 -1
- package/esm2015/testing.js +370 -0
- package/esm2015/testing.js.map +1 -0
- package/esm2015/text-field.js +1 -1
- package/esm2015/text-field.js.map +1 -1
- package/esm5/a11y.es5.js +10 -2
- package/esm5/a11y.es5.js.map +1 -1
- package/esm5/cdk.es5.js +1 -1
- package/esm5/cdk.es5.js.map +1 -1
- package/esm5/drag-drop.es5.js +241 -38
- package/esm5/drag-drop.es5.js.map +1 -1
- package/esm5/overlay.es5.js +15 -8
- package/esm5/overlay.es5.js.map +1 -1
- package/esm5/platform.es5.js +21 -1
- package/esm5/platform.es5.js.map +1 -1
- package/esm5/scrolling.es5.js +1 -1
- package/esm5/scrolling.es5.js.map +1 -1
- package/esm5/stepper.es5.js +49 -43
- package/esm5/stepper.es5.js.map +1 -1
- package/esm5/table.es5.js +4 -4
- package/esm5/table.es5.js.map +1 -1
- package/esm5/testing.es5.js +390 -0
- package/esm5/testing.es5.js.map +1 -0
- package/esm5/text-field.es5.js +3 -3
- package/esm5/text-field.es5.js.map +1 -1
- package/overlay/typings/index.metadata.json +1 -1
- package/overlay/typings/position/flexible-connected-position-strategy.d.ts +5 -2
- package/overlay/typings/public-api.d.ts +1 -1
- package/package.json +4 -4
- package/platform/typings/features/shadow-dom.d.ts +9 -0
- package/platform/typings/index.metadata.json +1 -1
- package/platform/typings/public-api.d.ts +1 -0
- package/schematics/ng-update/index.js +2 -2
- package/schematics/ng-update/index.js.map +1 -1
- package/schematics/ng-update/test-cases/misc/global-stylesheets-test.css +1 -0
- package/schematics/ng-update/upgrade-rules/class-inheritance-rule.js +3 -3
- package/schematics/ng-update/upgrade-rules/class-inheritance-rule.js.map +1 -1
- package/schematics/tsconfig.tsbuildinfo +2898 -2898
- package/schematics/update-tool/index.js +9 -5
- package/schematics/update-tool/index.js.map +1 -1
- package/scrolling/typings/virtual-scroll-viewport.d.ts +1 -1
- package/stepper/typings/index.metadata.json +1 -1
- package/stepper/typings/stepper.d.ts +3 -3
- package/table/typings/table.d.ts +4 -4
- package/testing/index.d.ts +8 -0
- package/testing/index.metadata.json +12 -0
- package/testing/package.json +8 -0
- package/testing/typings/dispatch-events.d.ts +33 -0
- package/testing/typings/element-focus.d.ts +18 -0
- package/testing/typings/event-objects.d.ts +34 -0
- package/testing/typings/index.d.ts +4 -0
- package/testing/typings/index.metadata.json +1 -0
- package/testing/typings/public-api.d.ts +11 -0
- package/testing/typings/type-in-element.d.ts +41 -0
- package/testing.d.ts +8 -0
- package/testing.metadata.json +12 -0
- package/text-field/typings/autosize.d.ts +1 -1
- package/typings/a11y/index.metadata.json +1 -1
- package/typings/a11y/key-manager/focus-key-manager.d.ts +1 -1
- package/typings/drag-drop/drag-ref.d.ts +9 -0
- package/typings/drag-drop/drop-list-ref.d.ts +7 -1
- package/typings/drag-drop/index.metadata.json +1 -1
- package/typings/esm5/a11y/index.metadata.json +1 -1
- package/typings/esm5/a11y/key-manager/focus-key-manager.d.ts +1 -1
- package/typings/esm5/drag-drop/drag-ref.d.ts +9 -0
- package/typings/esm5/drag-drop/drop-list-ref.d.ts +7 -1
- package/typings/esm5/drag-drop/index.metadata.json +1 -1
- package/typings/esm5/index.metadata.json +1 -1
- package/typings/esm5/overlay/index.metadata.json +1 -1
- package/typings/esm5/overlay/position/flexible-connected-position-strategy.d.ts +5 -2
- package/typings/esm5/overlay/public-api.d.ts +1 -1
- package/typings/esm5/platform/features/shadow-dom.d.ts +9 -0
- package/typings/esm5/platform/index.metadata.json +1 -1
- package/typings/esm5/platform/public-api.d.ts +1 -0
- package/typings/esm5/scrolling/virtual-scroll-viewport.d.ts +1 -1
- package/typings/esm5/stepper/index.metadata.json +1 -1
- package/typings/esm5/stepper/stepper.d.ts +3 -3
- package/typings/esm5/table/table.d.ts +4 -4
- package/typings/esm5/testing/dispatch-events.d.ts +33 -0
- package/typings/esm5/testing/element-focus.d.ts +18 -0
- package/typings/esm5/testing/event-objects.d.ts +34 -0
- package/typings/esm5/testing/index.d.ts +4 -0
- package/typings/esm5/testing/index.metadata.json +1 -0
- package/typings/esm5/testing/public-api.d.ts +11 -0
- package/typings/esm5/testing/type-in-element.d.ts +41 -0
- package/typings/esm5/text-field/autosize.d.ts +1 -1
- package/typings/index.metadata.json +1 -1
- package/typings/overlay/index.metadata.json +1 -1
- package/typings/overlay/position/flexible-connected-position-strategy.d.ts +5 -2
- package/typings/overlay/public-api.d.ts +1 -1
- package/typings/platform/features/shadow-dom.d.ts +9 -0
- package/typings/platform/index.metadata.json +1 -1
- package/typings/platform/public-api.d.ts +1 -0
- package/typings/scrolling/virtual-scroll-viewport.d.ts +1 -1
- package/typings/stepper/index.metadata.json +1 -1
- package/typings/stepper/stepper.d.ts +3 -3
- package/typings/table/table.d.ts +4 -4
- package/typings/testing/dispatch-events.d.ts +33 -0
- package/typings/testing/element-focus.d.ts +18 -0
- package/typings/testing/event-objects.d.ts +34 -0
- package/typings/testing/index.d.ts +4 -0
- package/typings/testing/index.metadata.json +1 -0
- package/typings/testing/public-api.d.ts +11 -0
- package/typings/testing/type-in-element.d.ts +41 -0
- package/typings/text-field/autosize.d.ts +1 -1
package/esm2015/cdk.js
CHANGED
package/esm2015/cdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cdk.js","sources":["../../src/cdk/version.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {Version} from '@angular/core';\n\n/** Current version of the Angular Component Development Kit. */\nexport const VERSION = new Version('8.
|
|
1
|
+
{"version":3,"file":"cdk.js","sources":["../../src/cdk/version.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {Version} from '@angular/core';\n\n/** Current version of the Angular Component Development Kit. */\nexport const VERSION = new Version('8.2.3');\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAWA,AAAA,MAAa,OAAO,GAAG,IAAI,OAAO,CAAC,mBAAmB,CAAC;;;;;;;;;;;;;;"}
|
package/esm2015/drag-drop.js
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
|
-
import { normalizePassiveListenerOptions } from '@angular/cdk/platform';
|
|
8
|
+
import { normalizePassiveListenerOptions, _supportsShadowDom } from '@angular/cdk/platform';
|
|
9
9
|
import { coerceBooleanProperty, coerceElement, coerceNumberProperty, coerceArray } from '@angular/cdk/coercion';
|
|
10
10
|
import { Subscription, Subject, interval, animationFrameScheduler, Observable, merge } from 'rxjs';
|
|
11
11
|
import { startWith, takeUntil, take, map, switchMap, tap } from 'rxjs/operators';
|
|
12
|
-
import {
|
|
12
|
+
import { Injectable, NgZone, Inject, InjectionToken, NgModule, ContentChildren, ElementRef, EventEmitter, forwardRef, Input, Output, Optional, Directive, ChangeDetectorRef, SkipSelf, ContentChild, ViewContainerRef, isDevMode, TemplateRef, ɵɵdefineInjectable, ɵɵinject } from '@angular/core';
|
|
13
13
|
import { DOCUMENT } from '@angular/common';
|
|
14
14
|
import { ViewportRuler } from '@angular/cdk/scrolling';
|
|
15
15
|
import { Directionality } from '@angular/cdk/bidi';
|
|
@@ -28,7 +28,7 @@ import { Directionality } from '@angular/cdk/bidi';
|
|
|
28
28
|
function extendStyles(dest, source) {
|
|
29
29
|
for (let key in source) {
|
|
30
30
|
if (source.hasOwnProperty(key)) {
|
|
31
|
-
dest[
|
|
31
|
+
dest[key] = (/** @type {?} */ (source[key]));
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
return dest;
|
|
@@ -186,6 +186,10 @@ class DragRef {
|
|
|
186
186
|
* Subscription to the viewport being scrolled.
|
|
187
187
|
*/
|
|
188
188
|
this._scrollSubscription = Subscription.EMPTY;
|
|
189
|
+
/**
|
|
190
|
+
* Subscription to the viewport being resized.
|
|
191
|
+
*/
|
|
192
|
+
this._resizeSubscription = Subscription.EMPTY;
|
|
189
193
|
/**
|
|
190
194
|
* Cached reference to the boundary element.
|
|
191
195
|
*/
|
|
@@ -486,6 +490,15 @@ class DragRef {
|
|
|
486
490
|
*/
|
|
487
491
|
withBoundaryElement(boundaryElement) {
|
|
488
492
|
(/** @type {?} */ (this))._boundaryElement = boundaryElement ? coerceElement(boundaryElement) : null;
|
|
493
|
+
(/** @type {?} */ (this))._resizeSubscription.unsubscribe();
|
|
494
|
+
if (boundaryElement) {
|
|
495
|
+
(/** @type {?} */ (this))._resizeSubscription = (/** @type {?} */ (this))._viewportRuler
|
|
496
|
+
.change(10)
|
|
497
|
+
.subscribe((/**
|
|
498
|
+
* @return {?}
|
|
499
|
+
*/
|
|
500
|
+
() => (/** @type {?} */ (this))._containInsideBoundaryOnResize()));
|
|
501
|
+
}
|
|
489
502
|
return (/** @type {?} */ (this));
|
|
490
503
|
}
|
|
491
504
|
/**
|
|
@@ -662,6 +675,7 @@ class DragRef {
|
|
|
662
675
|
}
|
|
663
676
|
this._removeSubscriptions();
|
|
664
677
|
this._dragDropRegistry.stopDragging(this);
|
|
678
|
+
this._toggleNativeDragInteractions();
|
|
665
679
|
if (this._handles) {
|
|
666
680
|
this._rootElement.style.webkitTapHighlightColor = this._rootElementTapHighlight;
|
|
667
681
|
}
|
|
@@ -677,6 +691,7 @@ class DragRef {
|
|
|
677
691
|
*/
|
|
678
692
|
() => {
|
|
679
693
|
this._cleanupDragArtifacts(event);
|
|
694
|
+
this._cleanupCachedDimensions();
|
|
680
695
|
this._dragDropRegistry.stopDragging(this);
|
|
681
696
|
}));
|
|
682
697
|
}
|
|
@@ -695,6 +710,7 @@ class DragRef {
|
|
|
695
710
|
distance: this._getDragDistance(this._getPointerPositionOnPage(event))
|
|
696
711
|
});
|
|
697
712
|
}));
|
|
713
|
+
this._cleanupCachedDimensions();
|
|
698
714
|
this._dragDropRegistry.stopDragging(this);
|
|
699
715
|
}
|
|
700
716
|
}
|
|
@@ -863,7 +879,7 @@ class DragRef {
|
|
|
863
879
|
// Drop container that draggable has been moved into.
|
|
864
880
|
/** @type {?} */
|
|
865
881
|
let newContainer = this._initialContainer._getSiblingContainerFromPosition(this, x, y);
|
|
866
|
-
// If we couldn't find a new container to move the item into, and the item has left
|
|
882
|
+
// If we couldn't find a new container to move the item into, and the item has left its
|
|
867
883
|
// initial container, check whether the it's over the initial container. This handles the
|
|
868
884
|
// case where two containers are connected one way and the user tries to undo dragging an
|
|
869
885
|
// item into a new container.
|
|
@@ -910,7 +926,7 @@ class DragRef {
|
|
|
910
926
|
if (previewTemplate) {
|
|
911
927
|
/** @type {?} */
|
|
912
928
|
const viewRef = (/** @type {?} */ (previewConfig)).viewContainer.createEmbeddedView(previewTemplate, (/** @type {?} */ (previewConfig)).context);
|
|
913
|
-
preview = viewRef.
|
|
929
|
+
preview = getRootNode(viewRef, this._document);
|
|
914
930
|
this._previewRef = viewRef;
|
|
915
931
|
preview.style.transform =
|
|
916
932
|
getTransform(this._pickupPositionOnPage.x, this._pickupPositionOnPage.y);
|
|
@@ -929,6 +945,8 @@ class DragRef {
|
|
|
929
945
|
// It's important that we disable the pointer events on the preview, because
|
|
930
946
|
// it can throw off the `document.elementFromPoint` calls in the `CdkDropList`.
|
|
931
947
|
pointerEvents: 'none',
|
|
948
|
+
// We have to reset the margin, because can throw off positioning relative to the viewport.
|
|
949
|
+
margin: '0',
|
|
932
950
|
position: 'fixed',
|
|
933
951
|
top: '0',
|
|
934
952
|
left: '0',
|
|
@@ -1008,7 +1026,7 @@ class DragRef {
|
|
|
1008
1026
|
let placeholder;
|
|
1009
1027
|
if (placeholderTemplate) {
|
|
1010
1028
|
this._placeholderRef = (/** @type {?} */ (placeholderConfig)).viewContainer.createEmbeddedView(placeholderTemplate, (/** @type {?} */ (placeholderConfig)).context);
|
|
1011
|
-
placeholder = this._placeholderRef.
|
|
1029
|
+
placeholder = getRootNode(this._placeholderRef, this._document);
|
|
1012
1030
|
}
|
|
1013
1031
|
else {
|
|
1014
1032
|
placeholder = deepCloneNode(this._rootElement);
|
|
@@ -1186,6 +1204,67 @@ class DragRef {
|
|
|
1186
1204
|
}
|
|
1187
1205
|
return { x: 0, y: 0 };
|
|
1188
1206
|
}
|
|
1207
|
+
/**
|
|
1208
|
+
* Cleans up any cached element dimensions that we don't need after dragging has stopped.
|
|
1209
|
+
* @private
|
|
1210
|
+
* @return {?}
|
|
1211
|
+
*/
|
|
1212
|
+
_cleanupCachedDimensions() {
|
|
1213
|
+
this._boundaryRect = this._previewRect = undefined;
|
|
1214
|
+
}
|
|
1215
|
+
/**
|
|
1216
|
+
* Checks whether the element is still inside its boundary after the viewport has been resized.
|
|
1217
|
+
* If not, the position is adjusted so that the element fits again.
|
|
1218
|
+
* @private
|
|
1219
|
+
* @return {?}
|
|
1220
|
+
*/
|
|
1221
|
+
_containInsideBoundaryOnResize() {
|
|
1222
|
+
let { x, y } = this._passiveTransform;
|
|
1223
|
+
if ((x === 0 && y === 0) || this.isDragging() || !this._boundaryElement) {
|
|
1224
|
+
return;
|
|
1225
|
+
}
|
|
1226
|
+
/** @type {?} */
|
|
1227
|
+
const boundaryRect = this._boundaryElement.getBoundingClientRect();
|
|
1228
|
+
/** @type {?} */
|
|
1229
|
+
const elementRect = this._rootElement.getBoundingClientRect();
|
|
1230
|
+
/** @type {?} */
|
|
1231
|
+
const leftOverflow = boundaryRect.left - elementRect.left;
|
|
1232
|
+
/** @type {?} */
|
|
1233
|
+
const rightOverflow = elementRect.right - boundaryRect.right;
|
|
1234
|
+
/** @type {?} */
|
|
1235
|
+
const topOverflow = boundaryRect.top - elementRect.top;
|
|
1236
|
+
/** @type {?} */
|
|
1237
|
+
const bottomOverflow = elementRect.bottom - boundaryRect.bottom;
|
|
1238
|
+
// If the element has become wider than the boundary, we can't
|
|
1239
|
+
// do much to make it fit so we just anchor it to the left.
|
|
1240
|
+
if (boundaryRect.width > elementRect.width) {
|
|
1241
|
+
if (leftOverflow > 0) {
|
|
1242
|
+
x += leftOverflow;
|
|
1243
|
+
}
|
|
1244
|
+
if (rightOverflow > 0) {
|
|
1245
|
+
x -= rightOverflow;
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1248
|
+
else {
|
|
1249
|
+
x = 0;
|
|
1250
|
+
}
|
|
1251
|
+
// If the element has become taller than the boundary, we can't
|
|
1252
|
+
// do much to make it fit so we just anchor it to the top.
|
|
1253
|
+
if (boundaryRect.height > elementRect.height) {
|
|
1254
|
+
if (topOverflow > 0) {
|
|
1255
|
+
y += topOverflow;
|
|
1256
|
+
}
|
|
1257
|
+
if (bottomOverflow > 0) {
|
|
1258
|
+
y -= bottomOverflow;
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
else {
|
|
1262
|
+
y = 0;
|
|
1263
|
+
}
|
|
1264
|
+
if (x !== this._passiveTransform.x || y !== this._passiveTransform.y) {
|
|
1265
|
+
this.setFreeDragPosition({ y, x });
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1189
1268
|
}
|
|
1190
1269
|
/**
|
|
1191
1270
|
* Gets a 3d `transform` that can be applied to an element.
|
|
@@ -1276,6 +1355,24 @@ function getPreviewInsertionPoint(documentRef) {
|
|
|
1276
1355
|
documentRef.msFullscreenElement ||
|
|
1277
1356
|
documentRef.body;
|
|
1278
1357
|
}
|
|
1358
|
+
/**
|
|
1359
|
+
* Gets the root HTML element of an embedded view.
|
|
1360
|
+
* If the root is not an HTML element it gets wrapped in one.
|
|
1361
|
+
* @param {?} viewRef
|
|
1362
|
+
* @param {?} _document
|
|
1363
|
+
* @return {?}
|
|
1364
|
+
*/
|
|
1365
|
+
function getRootNode(viewRef, _document) {
|
|
1366
|
+
/** @type {?} */
|
|
1367
|
+
const rootNode = viewRef.rootNodes[0];
|
|
1368
|
+
if (rootNode.nodeType !== _document.ELEMENT_NODE) {
|
|
1369
|
+
/** @type {?} */
|
|
1370
|
+
const wrapper = _document.createElement('div');
|
|
1371
|
+
wrapper.appendChild(rootNode);
|
|
1372
|
+
return wrapper;
|
|
1373
|
+
}
|
|
1374
|
+
return (/** @type {?} */ (rootNode));
|
|
1375
|
+
}
|
|
1279
1376
|
|
|
1280
1377
|
/**
|
|
1281
1378
|
* @fileoverview added by tsickle
|
|
@@ -1410,7 +1507,7 @@ class DropListRef {
|
|
|
1410
1507
|
/**
|
|
1411
1508
|
* Whether sorting items within the list is disabled.
|
|
1412
1509
|
*/
|
|
1413
|
-
this.sortingDisabled =
|
|
1510
|
+
this.sortingDisabled = false;
|
|
1414
1511
|
/**
|
|
1415
1512
|
* Whether auto-scrolling the view when the user
|
|
1416
1513
|
* moves their pointer close to the edges is disabled.
|
|
@@ -1542,9 +1639,10 @@ class DropListRef {
|
|
|
1542
1639
|
}
|
|
1543
1640
|
}));
|
|
1544
1641
|
});
|
|
1642
|
+
/** @type {?} */
|
|
1643
|
+
const nativeNode = this.element = coerceElement(element);
|
|
1644
|
+
this._shadowRoot = getShadowRoot(nativeNode) || _document;
|
|
1545
1645
|
_dragDropRegistry.registerDropContainer(this);
|
|
1546
|
-
this._document = _document;
|
|
1547
|
-
this.element = element instanceof ElementRef ? element.nativeElement : element;
|
|
1548
1646
|
}
|
|
1549
1647
|
/**
|
|
1550
1648
|
* Removes the drop list functionality from the DOM element.
|
|
@@ -1598,17 +1696,7 @@ class DropListRef {
|
|
|
1598
1696
|
}
|
|
1599
1697
|
// @breaking-change 9.0.0 Remove check for _viewportRuler once it's marked as a required param.
|
|
1600
1698
|
if (this._viewportRuler) {
|
|
1601
|
-
this.
|
|
1602
|
-
this._viewportScrollSubscription = this._dragDropRegistry.scroll.subscribe((/**
|
|
1603
|
-
* @return {?}
|
|
1604
|
-
*/
|
|
1605
|
-
() => {
|
|
1606
|
-
if (this.isDragging()) {
|
|
1607
|
-
/** @type {?} */
|
|
1608
|
-
const newPosition = (/** @type {?} */ (this._viewportRuler)).getViewportScrollPosition();
|
|
1609
|
-
this._updateAfterScroll(this._viewportScrollPosition, newPosition.top, newPosition.left, this._clientRect);
|
|
1610
|
-
}
|
|
1611
|
-
}));
|
|
1699
|
+
this._listenToScrollEvents();
|
|
1612
1700
|
}
|
|
1613
1701
|
}
|
|
1614
1702
|
/**
|
|
@@ -1889,9 +1977,19 @@ class DropListRef {
|
|
|
1889
1977
|
let verticalScrollDirection = 0 /* NONE */;
|
|
1890
1978
|
/** @type {?} */
|
|
1891
1979
|
let horizontalScrollDirection = 0 /* NONE */;
|
|
1980
|
+
// Check whether we should start scrolling the container.
|
|
1981
|
+
if (this._isPointerNearDropContainer(pointerX, pointerY)) {
|
|
1982
|
+
/** @type {?} */
|
|
1983
|
+
const element = coerceElement(this.element);
|
|
1984
|
+
[verticalScrollDirection, horizontalScrollDirection] =
|
|
1985
|
+
getElementScrollDirections(element, this._clientRect, pointerX, pointerY);
|
|
1986
|
+
if (verticalScrollDirection || horizontalScrollDirection) {
|
|
1987
|
+
scrollNode = element;
|
|
1988
|
+
}
|
|
1989
|
+
}
|
|
1892
1990
|
// @breaking-change 9.0.0 Remove null check for _viewportRuler once it's a required parameter.
|
|
1893
|
-
//
|
|
1894
|
-
if (this._viewportRuler) {
|
|
1991
|
+
// Otherwise check if we can start scrolling the viewport.
|
|
1992
|
+
if (this._viewportRuler && !verticalScrollDirection && !horizontalScrollDirection) {
|
|
1895
1993
|
const { width, height } = this._viewportRuler.getViewportSize();
|
|
1896
1994
|
/** @type {?} */
|
|
1897
1995
|
const clientRect = { width, height, top: 0, right: width, bottom: height, left: 0 };
|
|
@@ -1899,19 +1997,6 @@ class DropListRef {
|
|
|
1899
1997
|
horizontalScrollDirection = getHorizontalScrollDirection(clientRect, pointerX);
|
|
1900
1998
|
scrollNode = window;
|
|
1901
1999
|
}
|
|
1902
|
-
// If we couldn't find a scroll direction based on the
|
|
1903
|
-
// window, try with the container, if the pointer is close by.
|
|
1904
|
-
if (!verticalScrollDirection && !horizontalScrollDirection &&
|
|
1905
|
-
this._isPointerNearDropContainer(pointerX, pointerY)) {
|
|
1906
|
-
verticalScrollDirection = getVerticalScrollDirection(this._clientRect, pointerY);
|
|
1907
|
-
horizontalScrollDirection = getHorizontalScrollDirection(this._clientRect, pointerX);
|
|
1908
|
-
scrollNode = coerceElement(this.element);
|
|
1909
|
-
}
|
|
1910
|
-
// TODO(crisbeto): we also need to account for whether the view or element are scrollable in
|
|
1911
|
-
// the first place. With the current approach we'll still try to scroll them, but it just
|
|
1912
|
-
// won't do anything. The only case where this is relevant is that if we have a scrollable
|
|
1913
|
-
// list close to the viewport edge where the viewport isn't scrollable. In this case the
|
|
1914
|
-
// we'll be trying to scroll the viewport rather than the list.
|
|
1915
2000
|
if (scrollNode && (verticalScrollDirection !== this._verticalScrollDirection ||
|
|
1916
2001
|
horizontalScrollDirection !== this._horizontalScrollDirection ||
|
|
1917
2002
|
scrollNode !== this._scrollNode)) {
|
|
@@ -2217,7 +2302,7 @@ class DropListRef {
|
|
|
2217
2302
|
return false;
|
|
2218
2303
|
}
|
|
2219
2304
|
/** @type {?} */
|
|
2220
|
-
const elementFromPoint = (/** @type {?} */ (this.
|
|
2305
|
+
const elementFromPoint = (/** @type {?} */ (this._shadowRoot.elementFromPoint(x, y)));
|
|
2221
2306
|
// If there's no element at the pointer position, then
|
|
2222
2307
|
// the client rect is probably scrolled out of the view.
|
|
2223
2308
|
if (!elementFromPoint) {
|
|
@@ -2244,6 +2329,7 @@ class DropListRef {
|
|
|
2244
2329
|
if (!activeSiblings.has(sibling)) {
|
|
2245
2330
|
activeSiblings.add(sibling);
|
|
2246
2331
|
this._cacheOwnPosition();
|
|
2332
|
+
this._listenToScrollEvents();
|
|
2247
2333
|
}
|
|
2248
2334
|
}
|
|
2249
2335
|
/**
|
|
@@ -2253,6 +2339,29 @@ class DropListRef {
|
|
|
2253
2339
|
*/
|
|
2254
2340
|
_stopReceiving(sibling) {
|
|
2255
2341
|
this._activeSiblings.delete(sibling);
|
|
2342
|
+
this._viewportScrollSubscription.unsubscribe();
|
|
2343
|
+
}
|
|
2344
|
+
/**
|
|
2345
|
+
* Starts listening to scroll events on the viewport.
|
|
2346
|
+
* Used for updating the internal state of the list.
|
|
2347
|
+
* @private
|
|
2348
|
+
* @return {?}
|
|
2349
|
+
*/
|
|
2350
|
+
_listenToScrollEvents() {
|
|
2351
|
+
this._viewportScrollPosition = (/** @type {?} */ (this._viewportRuler)).getViewportScrollPosition();
|
|
2352
|
+
this._viewportScrollSubscription = this._dragDropRegistry.scroll.subscribe((/**
|
|
2353
|
+
* @return {?}
|
|
2354
|
+
*/
|
|
2355
|
+
() => {
|
|
2356
|
+
if (this.isDragging()) {
|
|
2357
|
+
/** @type {?} */
|
|
2358
|
+
const newPosition = (/** @type {?} */ (this._viewportRuler)).getViewportScrollPosition();
|
|
2359
|
+
this._updateAfterScroll(this._viewportScrollPosition, newPosition.top, newPosition.left, this._clientRect);
|
|
2360
|
+
}
|
|
2361
|
+
else if (this.isReceiving()) {
|
|
2362
|
+
this._cacheOwnPosition();
|
|
2363
|
+
}
|
|
2364
|
+
}));
|
|
2256
2365
|
}
|
|
2257
2366
|
}
|
|
2258
2367
|
/**
|
|
@@ -2382,6 +2491,69 @@ function getHorizontalScrollDirection(clientRect, pointerX) {
|
|
|
2382
2491
|
}
|
|
2383
2492
|
return 0 /* NONE */;
|
|
2384
2493
|
}
|
|
2494
|
+
/**
|
|
2495
|
+
* Gets the directions in which an element node should be scrolled,
|
|
2496
|
+
* assuming that the user's pointer is already within it scrollable region.
|
|
2497
|
+
* @param {?} element Element for which we should calculate the scroll direction.
|
|
2498
|
+
* @param {?} clientRect Bounding client rectangle of the element.
|
|
2499
|
+
* @param {?} pointerX Position of the user's pointer along the x axis.
|
|
2500
|
+
* @param {?} pointerY Position of the user's pointer along the y axis.
|
|
2501
|
+
* @return {?}
|
|
2502
|
+
*/
|
|
2503
|
+
function getElementScrollDirections(element, clientRect, pointerX, pointerY) {
|
|
2504
|
+
/** @type {?} */
|
|
2505
|
+
const computedVertical = getVerticalScrollDirection(clientRect, pointerY);
|
|
2506
|
+
/** @type {?} */
|
|
2507
|
+
const computedHorizontal = getHorizontalScrollDirection(clientRect, pointerX);
|
|
2508
|
+
/** @type {?} */
|
|
2509
|
+
let verticalScrollDirection = 0 /* NONE */;
|
|
2510
|
+
/** @type {?} */
|
|
2511
|
+
let horizontalScrollDirection = 0 /* NONE */;
|
|
2512
|
+
// Note that we here we do some extra checks for whether the element is actually scrollable in
|
|
2513
|
+
// a certain direction and we only assign the scroll direction if it is. We do this so that we
|
|
2514
|
+
// can allow other elements to be scrolled, if the current element can't be scrolled anymore.
|
|
2515
|
+
// This allows us to handle cases where the scroll regions of two scrollable elements overlap.
|
|
2516
|
+
if (computedVertical) {
|
|
2517
|
+
/** @type {?} */
|
|
2518
|
+
const scrollTop = element.scrollTop;
|
|
2519
|
+
if (computedVertical === 1 /* UP */) {
|
|
2520
|
+
if (scrollTop > 0) {
|
|
2521
|
+
verticalScrollDirection = 1 /* UP */;
|
|
2522
|
+
}
|
|
2523
|
+
}
|
|
2524
|
+
else if (element.scrollHeight - scrollTop > element.clientHeight) {
|
|
2525
|
+
verticalScrollDirection = 2 /* DOWN */;
|
|
2526
|
+
}
|
|
2527
|
+
}
|
|
2528
|
+
if (computedHorizontal) {
|
|
2529
|
+
/** @type {?} */
|
|
2530
|
+
const scrollLeft = element.scrollLeft;
|
|
2531
|
+
if (computedHorizontal === 1 /* LEFT */) {
|
|
2532
|
+
if (scrollLeft > 0) {
|
|
2533
|
+
horizontalScrollDirection = 1 /* LEFT */;
|
|
2534
|
+
}
|
|
2535
|
+
}
|
|
2536
|
+
else if (element.scrollWidth - scrollLeft > element.clientWidth) {
|
|
2537
|
+
horizontalScrollDirection = 2 /* RIGHT */;
|
|
2538
|
+
}
|
|
2539
|
+
}
|
|
2540
|
+
return [verticalScrollDirection, horizontalScrollDirection];
|
|
2541
|
+
}
|
|
2542
|
+
/**
|
|
2543
|
+
* Gets the shadow root of an element, if any.
|
|
2544
|
+
* @param {?} element
|
|
2545
|
+
* @return {?}
|
|
2546
|
+
*/
|
|
2547
|
+
function getShadowRoot(element) {
|
|
2548
|
+
if (_supportsShadowDom()) {
|
|
2549
|
+
/** @type {?} */
|
|
2550
|
+
const rootNode = element.getRootNode ? element.getRootNode() : null;
|
|
2551
|
+
if (rootNode instanceof ShadowRoot) {
|
|
2552
|
+
return rootNode;
|
|
2553
|
+
}
|
|
2554
|
+
}
|
|
2555
|
+
return null;
|
|
2556
|
+
}
|
|
2385
2557
|
|
|
2386
2558
|
/**
|
|
2387
2559
|
* @fileoverview added by tsickle
|
|
@@ -2554,7 +2726,10 @@ class DragDropRegistry {
|
|
|
2554
2726
|
* @param {?} e
|
|
2555
2727
|
* @return {?}
|
|
2556
2728
|
*/
|
|
2557
|
-
(e) => this.scroll.next(e))
|
|
2729
|
+
(e) => this.scroll.next(e)),
|
|
2730
|
+
// Use capturing so that we pick up scroll changes in any scrollable nodes that aren't
|
|
2731
|
+
// the document. See https://github.com/angular/components/issues/17144.
|
|
2732
|
+
options: true
|
|
2558
2733
|
})
|
|
2559
2734
|
// Preventing the default action on `mousemove` isn't enough to disable text selection
|
|
2560
2735
|
// on Safari so we need to prevent the selection event as well. Alternatively this can
|