@angular/cdk 9.2.1 → 9.2.2
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/focus-monitor/focus-monitor.d.ts +10 -3
- package/a11y/high-contrast-mode/high-contrast-mode-detector.d.ts +2 -2
- package/a11y/index.metadata.json +1 -1
- package/bundles/cdk-a11y.umd.js +62 -27
- package/bundles/cdk-a11y.umd.js.map +1 -1
- package/bundles/cdk-a11y.umd.min.js +12 -5
- package/bundles/cdk-a11y.umd.min.js.map +1 -1
- package/bundles/cdk-drag-drop.umd.js +193 -109
- package/bundles/cdk-drag-drop.umd.js.map +1 -1
- package/bundles/cdk-drag-drop.umd.min.js +17 -10
- package/bundles/cdk-drag-drop.umd.min.js.map +1 -1
- package/bundles/cdk-overlay.umd.js.map +1 -1
- package/bundles/cdk-platform.umd.js +3 -1
- package/bundles/cdk-platform.umd.js.map +1 -1
- package/bundles/cdk-platform.umd.min.js +4 -4
- package/bundles/cdk-platform.umd.min.js.map +1 -1
- package/bundles/cdk-scrolling.umd.js +18 -3
- package/bundles/cdk-scrolling.umd.js.map +1 -1
- package/bundles/cdk-scrolling.umd.min.js +2 -2
- package/bundles/cdk-scrolling.umd.min.js.map +1 -1
- package/bundles/cdk-testing-testbed.umd.js +62 -10
- package/bundles/cdk-testing-testbed.umd.js.map +1 -1
- package/bundles/cdk-testing-testbed.umd.min.js +5 -5
- package/bundles/cdk-testing-testbed.umd.min.js.map +1 -1
- package/bundles/cdk-tree.umd.js +1 -0
- package/bundles/cdk-tree.umd.js.map +1 -1
- package/bundles/cdk-tree.umd.min.js +1 -1
- package/bundles/cdk-tree.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/drag-ref.d.ts +4 -2
- package/drag-drop/drop-list-ref.d.ts +9 -8
- package/drag-drop/index.metadata.json +1 -1
- package/drag-drop/parent-position-tracker.d.ts +31 -0
- package/drag-drop/public-api.d.ts +1 -1
- package/esm2015/a11y/aria-describer/aria-reference.js +6 -6
- package/esm2015/a11y/focus-monitor/focus-monitor.js +84 -26
- package/esm2015/a11y/high-contrast-mode/high-contrast-mode-detector.js +3 -3
- package/esm2015/drag-drop/drag-drop-module.js +3 -1
- package/esm2015/drag-drop/drag-ref.js +55 -35
- package/esm2015/drag-drop/drop-list-ref.js +115 -124
- package/esm2015/drag-drop/parent-position-tracker.js +141 -0
- package/esm2015/drag-drop/public-api.js +1 -1
- package/esm2015/overlay/position/flexible-connected-position-strategy.js +1 -1
- package/esm2015/platform/features/shadow-dom.js +4 -2
- package/esm2015/scrolling/public-api.js +2 -2
- package/esm2015/scrolling/scrolling-module.js +15 -4
- package/esm2015/testing/testbed/fake-events/dispatch-events.js +11 -4
- package/esm2015/testing/testbed/fake-events/event-objects.js +37 -3
- package/esm2015/testing/testbed/unit-test-element.js +13 -2
- package/esm2015/tree/tree.js +2 -1
- package/esm2015/version.js +1 -1
- package/esm5/a11y/aria-describer/aria-reference.js +6 -6
- package/esm5/a11y/focus-monitor/focus-monitor.js +57 -22
- package/esm5/a11y/high-contrast-mode/high-contrast-mode-detector.js +3 -3
- package/esm5/drag-drop/drag-drop-module.js +3 -1
- package/esm5/drag-drop/drag-ref.js +39 -26
- package/esm5/drag-drop/drop-list-ref.js +85 -86
- package/esm5/drag-drop/parent-position-tracker.js +74 -0
- package/esm5/drag-drop/public-api.js +1 -1
- package/esm5/overlay/position/flexible-connected-position-strategy.js +1 -1
- package/esm5/platform/features/shadow-dom.js +4 -2
- package/esm5/scrolling/scrolling-module.js +19 -4
- package/esm5/testing/testbed/fake-events/dispatch-events.js +15 -7
- package/esm5/testing/testbed/fake-events/event-objects.js +43 -5
- package/esm5/testing/testbed/unit-test-element.js +10 -3
- package/esm5/tree/tree.js +2 -1
- package/esm5/version.js +1 -1
- package/fesm2015/a11y.js +90 -32
- package/fesm2015/a11y.js.map +1 -1
- package/fesm2015/cdk.js +1 -1
- package/fesm2015/cdk.js.map +1 -1
- package/fesm2015/drag-drop.js +302 -158
- package/fesm2015/drag-drop.js.map +1 -1
- package/fesm2015/overlay.js.map +1 -1
- package/fesm2015/platform.js +3 -1
- package/fesm2015/platform.js.map +1 -1
- package/fesm2015/scrolling.js +15 -4
- package/fesm2015/scrolling.js.map +1 -1
- package/fesm2015/testing/testbed.js +56 -4
- package/fesm2015/testing/testbed.js.map +1 -1
- package/fesm2015/tree.js +1 -0
- package/fesm2015/tree.js.map +1 -1
- package/fesm5/a11y.js +63 -28
- package/fesm5/a11y.js.map +1 -1
- package/fesm5/cdk.js +1 -1
- package/fesm5/cdk.js.map +1 -1
- package/fesm5/drag-drop.js +195 -111
- package/fesm5/drag-drop.js.map +1 -1
- package/fesm5/overlay.js.map +1 -1
- package/fesm5/platform.js +3 -1
- package/fesm5/platform.js.map +1 -1
- package/fesm5/scrolling.js +18 -4
- package/fesm5/scrolling.js.map +1 -1
- package/fesm5/testing/testbed.js +63 -11
- package/fesm5/testing/testbed.js.map +1 -1
- package/fesm5/tree.js +1 -0
- package/fesm5/tree.js.map +1 -1
- package/overlay/position/flexible-connected-position-strategy.d.ts +1 -1
- package/package.json +1 -1
- package/schematics/ng-add/index.js +1 -1
- package/schematics/ng-update/devkit-file-system.d.ts +29 -0
- package/schematics/ng-update/devkit-file-system.js +67 -0
- package/schematics/ng-update/devkit-migration-rule.d.ts +25 -0
- package/schematics/ng-update/devkit-migration-rule.js +152 -0
- package/schematics/ng-update/devkit-migration.d.ts +37 -0
- package/schematics/ng-update/devkit-migration.js +29 -0
- package/schematics/ng-update/index.js +7 -7
- package/schematics/ng-update/{upgrade-rules/attribute-selectors-rule.d.ts → migrations/attribute-selectors.d.ts} +6 -6
- package/schematics/ng-update/migrations/attribute-selectors.js +76 -0
- package/schematics/ng-update/{upgrade-rules/class-inheritance-rule.d.ts → migrations/class-inheritance.d.ts} +6 -6
- package/schematics/ng-update/migrations/class-inheritance.js +67 -0
- package/schematics/ng-update/{upgrade-rules/class-names-rule.d.ts → migrations/class-names.d.ts} +6 -6
- package/schematics/ng-update/migrations/class-names.js +98 -0
- package/schematics/ng-update/{upgrade-rules/constructor-signature-rule.d.ts → migrations/constructor-signature.d.ts} +6 -6
- package/schematics/ng-update/migrations/constructor-signature.js +144 -0
- package/schematics/ng-update/{upgrade-rules/css-selectors-rule.d.ts → migrations/css-selectors.d.ts} +6 -6
- package/schematics/ng-update/migrations/css-selectors.js +83 -0
- package/schematics/ng-update/{upgrade-rules/element-selectors-rule.d.ts → migrations/element-selectors.d.ts} +6 -6
- package/schematics/ng-update/migrations/element-selectors.js +74 -0
- package/schematics/ng-update/{upgrade-rules/input-names-rule.d.ts → migrations/input-names.d.ts} +6 -6
- package/schematics/ng-update/migrations/input-names.js +69 -0
- package/schematics/ng-update/{upgrade-rules/method-call-arguments-rule.d.ts → migrations/method-call-arguments.d.ts} +6 -6
- package/schematics/ng-update/migrations/method-call-arguments.js +70 -0
- package/schematics/ng-update/{upgrade-rules/misc-template-rule.d.ts → migrations/misc-template.d.ts} +6 -6
- package/schematics/ng-update/migrations/misc-template.js +47 -0
- package/schematics/ng-update/{upgrade-rules/output-names-rule.d.ts → migrations/output-names.d.ts} +6 -6
- package/schematics/ng-update/migrations/output-names.js +56 -0
- package/schematics/ng-update/{upgrade-rules/property-names-rule.d.ts → migrations/property-names.d.ts} +6 -6
- package/schematics/ng-update/migrations/property-names.js +56 -0
- package/schematics/ng-update/public-api.d.ts +3 -2
- package/schematics/ng-update/public-api.js +5 -4
- package/schematics/ng-update/upgrade-data.d.ts +7 -8
- package/schematics/ng-update/upgrade-data.js +6 -7
- package/schematics/update-tool/component-resource-collector.d.ts +3 -1
- package/schematics/update-tool/component-resource-collector.js +8 -8
- package/schematics/update-tool/file-system.d.ts +38 -0
- package/schematics/update-tool/file-system.js +20 -0
- package/schematics/update-tool/index.d.ts +41 -11
- package/schematics/update-tool/index.js +135 -106
- package/schematics/update-tool/logger.d.ts +16 -0
- package/schematics/update-tool/logger.js +27 -0
- package/schematics/update-tool/{migration-rule.d.ts → migration.d.ts} +23 -45
- package/schematics/update-tool/migration.js +76 -0
- package/schematics/update-tool/public-api.d.ts +5 -4
- package/schematics/update-tool/public-api.js +6 -6
- package/schematics/update-tool/update-recorder.d.ts +14 -0
- package/schematics/update-tool/update-recorder.js +20 -0
- package/schematics/update-tool/utils/parse-tsconfig.js +1 -1
- package/schematics/update-tool/version-changes.js +3 -4
- package/scrolling/index.metadata.json +1 -1
- package/scrolling/scrolling-module.d.ts +2 -0
- package/testing/testbed/fake-events/dispatch-events.d.ts +8 -3
- package/testing/testbed/fake-events/event-objects.d.ts +12 -1
- package/tree/index.metadata.json +1 -1
- package/schematics/ng-update/upgrade-rules/attribute-selectors-rule.js +0 -76
- package/schematics/ng-update/upgrade-rules/class-inheritance-rule.js +0 -67
- package/schematics/ng-update/upgrade-rules/class-names-rule.js +0 -98
- package/schematics/ng-update/upgrade-rules/constructor-signature-rule.js +0 -144
- package/schematics/ng-update/upgrade-rules/css-selectors-rule.js +0 -83
- package/schematics/ng-update/upgrade-rules/element-selectors-rule.js +0 -74
- package/schematics/ng-update/upgrade-rules/index.d.ts +0 -22
- package/schematics/ng-update/upgrade-rules/index.js +0 -116
- package/schematics/ng-update/upgrade-rules/input-names-rule.js +0 -69
- package/schematics/ng-update/upgrade-rules/method-call-arguments-rule.js +0 -70
- package/schematics/ng-update/upgrade-rules/misc-template-rule.js +0 -47
- package/schematics/ng-update/upgrade-rules/output-names-rule.js +0 -56
- package/schematics/ng-update/upgrade-rules/property-names-rule.js +0 -56
- package/schematics/update-tool/migration-rule.js +0 -101
package/fesm5/cdk.js
CHANGED
|
@@ -8,7 +8,7 @@ import { Version } from '@angular/core';
|
|
|
8
8
|
* found in the LICENSE file at https://angular.io/license
|
|
9
9
|
*/
|
|
10
10
|
/** Current version of the Angular Component Development Kit. */
|
|
11
|
-
var VERSION = new Version('9.2.
|
|
11
|
+
var VERSION = new Version('9.2.2');
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* @license
|
package/fesm5/cdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cdk.js","sources":["../../../../../../src/cdk/version.ts","../../../../../../src/cdk/public-api.ts","../../../../../../src/cdk/index.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('9.2.
|
|
1
|
+
{"version":3,"file":"cdk.js","sources":["../../../../../../src/cdk/version.ts","../../../../../../src/cdk/public-api.ts","../../../../../../src/cdk/index.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('9.2.2');\n","/**\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\nexport * from './version';\n","/**\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\nexport * from './public-api';\n"],"names":[],"mappings":";;AAAA;;;;;;;AAQA,AAEA;AACA,IAAa,OAAO,GAAG,IAAI,OAAO,CAAC,mBAAmB,CAAC;;ACXvD;;;;;;GAMG;;ACNH;;;;;;GAMG;;;;"}
|
package/fesm5/drag-drop.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Injectable, NgZone, Inject, ɵɵdefineInjectable, ɵɵinject, InjectionToken, Directive, ElementRef, Optional, Input, TemplateRef, EventEmitter, isDevMode, SkipSelf, ViewContainerRef, ChangeDetectorRef, ContentChildren, ContentChild, Output, NgModule } from '@angular/core';
|
|
2
2
|
import { DOCUMENT } from '@angular/common';
|
|
3
|
-
import { ViewportRuler, ScrollDispatcher } from '@angular/cdk/scrolling';
|
|
3
|
+
import { ViewportRuler, ScrollDispatcher, CdkScrollableModule } from '@angular/cdk/scrolling';
|
|
4
4
|
import { normalizePassiveListenerOptions, _getShadowRoot } from '@angular/cdk/platform';
|
|
5
5
|
import { coerceBooleanProperty, coerceElement, coerceNumberProperty, coerceArray } from '@angular/cdk/coercion';
|
|
6
6
|
import { Subject, Subscription, interval, animationFrameScheduler, Observable, merge } from 'rxjs';
|
|
7
|
-
import { startWith, takeUntil, map, take, tap, switchMap } from 'rxjs/operators';
|
|
8
7
|
import { __spread, __read } from 'tslib';
|
|
8
|
+
import { takeUntil, map, take, startWith, tap, switchMap } from 'rxjs/operators';
|
|
9
9
|
import { Directionality } from '@angular/cdk/bidi';
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -142,6 +142,78 @@ function isPointerNearClientRect(rect, threshold, pointerX, pointerY) {
|
|
|
142
142
|
pointerX > left - xThreshold && pointerX < right + xThreshold;
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
+
/**
|
|
146
|
+
* @license
|
|
147
|
+
* Copyright Google LLC All Rights Reserved.
|
|
148
|
+
*
|
|
149
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
150
|
+
* found in the LICENSE file at https://angular.io/license
|
|
151
|
+
*/
|
|
152
|
+
/** Keeps track of the scroll position and dimensions of the parents of an element. */
|
|
153
|
+
var ParentPositionTracker = /** @class */ (function () {
|
|
154
|
+
function ParentPositionTracker(_document, _viewportRuler) {
|
|
155
|
+
this._document = _document;
|
|
156
|
+
this._viewportRuler = _viewportRuler;
|
|
157
|
+
/** Cached positions of the scrollable parent elements. */
|
|
158
|
+
this.positions = new Map();
|
|
159
|
+
}
|
|
160
|
+
/** Clears the cached positions. */
|
|
161
|
+
ParentPositionTracker.prototype.clear = function () {
|
|
162
|
+
this.positions.clear();
|
|
163
|
+
};
|
|
164
|
+
/** Caches the positions. Should be called at the beginning of a drag sequence. */
|
|
165
|
+
ParentPositionTracker.prototype.cache = function (elements) {
|
|
166
|
+
var _this = this;
|
|
167
|
+
this.clear();
|
|
168
|
+
this.positions.set(this._document, {
|
|
169
|
+
scrollPosition: this._viewportRuler.getViewportScrollPosition(),
|
|
170
|
+
});
|
|
171
|
+
elements.forEach(function (element) {
|
|
172
|
+
_this.positions.set(element, {
|
|
173
|
+
scrollPosition: { top: element.scrollTop, left: element.scrollLeft },
|
|
174
|
+
clientRect: getMutableClientRect(element)
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
/** Handles scrolling while a drag is taking place. */
|
|
179
|
+
ParentPositionTracker.prototype.handleScroll = function (event) {
|
|
180
|
+
var target = event.target;
|
|
181
|
+
var cachedPosition = this.positions.get(target);
|
|
182
|
+
if (!cachedPosition) {
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
// Used when figuring out whether an element is inside the scroll parent. If the scrolled
|
|
186
|
+
// parent is the `document`, we use the `documentElement`, because IE doesn't support
|
|
187
|
+
// `contains` on the `document`.
|
|
188
|
+
var scrolledParentNode = target === this._document ? target.documentElement : target;
|
|
189
|
+
var scrollPosition = cachedPosition.scrollPosition;
|
|
190
|
+
var newTop;
|
|
191
|
+
var newLeft;
|
|
192
|
+
if (target === this._document) {
|
|
193
|
+
var viewportScrollPosition = this._viewportRuler.getViewportScrollPosition();
|
|
194
|
+
newTop = viewportScrollPosition.top;
|
|
195
|
+
newLeft = viewportScrollPosition.left;
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
newTop = target.scrollTop;
|
|
199
|
+
newLeft = target.scrollLeft;
|
|
200
|
+
}
|
|
201
|
+
var topDifference = scrollPosition.top - newTop;
|
|
202
|
+
var leftDifference = scrollPosition.left - newLeft;
|
|
203
|
+
// Go through and update the cached positions of the scroll
|
|
204
|
+
// parents that are inside the element that was scrolled.
|
|
205
|
+
this.positions.forEach(function (position, node) {
|
|
206
|
+
if (position.clientRect && target !== node && scrolledParentNode.contains(node)) {
|
|
207
|
+
adjustClientRect(position.clientRect, topDifference, leftDifference);
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
scrollPosition.top = newTop;
|
|
211
|
+
scrollPosition.left = newLeft;
|
|
212
|
+
return { top: topDifference, left: leftDifference };
|
|
213
|
+
};
|
|
214
|
+
return ParentPositionTracker;
|
|
215
|
+
}());
|
|
216
|
+
|
|
145
217
|
/**
|
|
146
218
|
* @license
|
|
147
219
|
* Copyright Google LLC All Rights Reserved.
|
|
@@ -319,6 +391,7 @@ var DragRef = /** @class */ (function () {
|
|
|
319
391
|
_this._endDragSequence(event);
|
|
320
392
|
};
|
|
321
393
|
this.withRootElement(element);
|
|
394
|
+
this._parentPositions = new ParentPositionTracker(_document, _viewportRuler);
|
|
322
395
|
_dragDropRegistry.registerDragItem(this);
|
|
323
396
|
}
|
|
324
397
|
Object.defineProperty(DragRef.prototype, "disabled", {
|
|
@@ -439,6 +512,7 @@ var DragRef = /** @class */ (function () {
|
|
|
439
512
|
this._disabledHandles.clear();
|
|
440
513
|
this._dropContainer = undefined;
|
|
441
514
|
this._resizeSubscription.unsubscribe();
|
|
515
|
+
this._parentPositions.clear();
|
|
442
516
|
this._boundaryElement = this._rootElement = this._placeholderTemplate =
|
|
443
517
|
this._previewTemplate = this._anchor = null;
|
|
444
518
|
};
|
|
@@ -586,7 +660,8 @@ var DragRef = /** @class */ (function () {
|
|
|
586
660
|
this._lastTouchEventTime = Date.now();
|
|
587
661
|
}
|
|
588
662
|
this._toggleNativeDragInteractions();
|
|
589
|
-
|
|
663
|
+
var dropContainer = this._dropContainer;
|
|
664
|
+
if (dropContainer) {
|
|
590
665
|
var element = this._rootElement;
|
|
591
666
|
var parent_1 = element.parentNode;
|
|
592
667
|
var preview = this._preview = this._createPreviewElement();
|
|
@@ -600,13 +675,16 @@ var DragRef = /** @class */ (function () {
|
|
|
600
675
|
element.style.display = 'none';
|
|
601
676
|
this._document.body.appendChild(parent_1.replaceChild(placeholder, element));
|
|
602
677
|
getPreviewInsertionPoint(this._document).appendChild(preview);
|
|
603
|
-
|
|
604
|
-
this._initialContainer =
|
|
605
|
-
this._initialIndex =
|
|
678
|
+
dropContainer.start();
|
|
679
|
+
this._initialContainer = dropContainer;
|
|
680
|
+
this._initialIndex = dropContainer.getItemIndex(this);
|
|
606
681
|
}
|
|
607
682
|
else {
|
|
608
683
|
this._initialContainer = this._initialIndex = undefined;
|
|
609
684
|
}
|
|
685
|
+
// Important to run after we've called `start` on the parent container
|
|
686
|
+
// so that it has had time to resolve its scrollable parents.
|
|
687
|
+
this._parentPositions.cache(dropContainer ? dropContainer.getScrollableParents() : []);
|
|
610
688
|
};
|
|
611
689
|
/**
|
|
612
690
|
* Sets up the different variables and subscriptions
|
|
@@ -652,8 +730,8 @@ var DragRef = /** @class */ (function () {
|
|
|
652
730
|
this._removeSubscriptions();
|
|
653
731
|
this._pointerMoveSubscription = this._dragDropRegistry.pointerMove.subscribe(this._pointerMove);
|
|
654
732
|
this._pointerUpSubscription = this._dragDropRegistry.pointerUp.subscribe(this._pointerUp);
|
|
655
|
-
this._scrollSubscription = this._dragDropRegistry.scroll.
|
|
656
|
-
_this._updateOnScroll();
|
|
733
|
+
this._scrollSubscription = this._dragDropRegistry.scroll.subscribe(function (scrollEvent) {
|
|
734
|
+
_this._updateOnScroll(scrollEvent);
|
|
657
735
|
});
|
|
658
736
|
if (this._boundaryElement) {
|
|
659
737
|
this._boundaryRect = getMutableClientRect(this._boundaryElement);
|
|
@@ -753,13 +831,16 @@ var DragRef = /** @class */ (function () {
|
|
|
753
831
|
var previewClass = this.previewClass;
|
|
754
832
|
var previewTemplate = previewConfig ? previewConfig.template : null;
|
|
755
833
|
var preview;
|
|
756
|
-
if (previewTemplate) {
|
|
834
|
+
if (previewTemplate && previewConfig) {
|
|
835
|
+
// Measure the element before we've inserted the preview
|
|
836
|
+
// since the insertion could throw off the measurement.
|
|
837
|
+
var rootRect = previewConfig.matchSize ? this._rootElement.getBoundingClientRect() : null;
|
|
757
838
|
var viewRef = previewConfig.viewContainer.createEmbeddedView(previewTemplate, previewConfig.context);
|
|
758
839
|
viewRef.detectChanges();
|
|
759
840
|
preview = getRootNode(viewRef, this._document);
|
|
760
841
|
this._previewRef = viewRef;
|
|
761
842
|
if (previewConfig.matchSize) {
|
|
762
|
-
matchElementSize(preview,
|
|
843
|
+
matchElementSize(preview, rootRect);
|
|
763
844
|
}
|
|
764
845
|
else {
|
|
765
846
|
preview.style.transform =
|
|
@@ -769,7 +850,7 @@ var DragRef = /** @class */ (function () {
|
|
|
769
850
|
else {
|
|
770
851
|
var element = this._rootElement;
|
|
771
852
|
preview = deepCloneNode(element);
|
|
772
|
-
matchElementSize(preview, element);
|
|
853
|
+
matchElementSize(preview, element.getBoundingClientRect());
|
|
773
854
|
}
|
|
774
855
|
extendStyles(preview.style, {
|
|
775
856
|
// It's important that we disable the pointer events on the preview, because
|
|
@@ -861,8 +942,9 @@ var DragRef = /** @class */ (function () {
|
|
|
861
942
|
var handleElement = referenceElement === this._rootElement ? null : referenceElement;
|
|
862
943
|
var referenceRect = handleElement ? handleElement.getBoundingClientRect() : elementRect;
|
|
863
944
|
var point = isTouchEvent(event) ? event.targetTouches[0] : event;
|
|
864
|
-
var
|
|
865
|
-
var
|
|
945
|
+
var scrollPosition = this._getViewportScrollPosition();
|
|
946
|
+
var x = point.pageX - referenceRect.left - scrollPosition.left;
|
|
947
|
+
var y = point.pageY - referenceRect.top - scrollPosition.top;
|
|
866
948
|
return {
|
|
867
949
|
x: referenceRect.left - elementRect.left + x,
|
|
868
950
|
y: referenceRect.top - elementRect.top + y
|
|
@@ -872,9 +954,10 @@ var DragRef = /** @class */ (function () {
|
|
|
872
954
|
DragRef.prototype._getPointerPositionOnPage = function (event) {
|
|
873
955
|
// `touches` will be empty for start/end events so we have to fall back to `changedTouches`.
|
|
874
956
|
var point = isTouchEvent(event) ? (event.touches[0] || event.changedTouches[0]) : event;
|
|
957
|
+
var scrollPosition = this._getViewportScrollPosition();
|
|
875
958
|
return {
|
|
876
|
-
x: point.pageX -
|
|
877
|
-
y: point.pageY -
|
|
959
|
+
x: point.pageX - scrollPosition.left,
|
|
960
|
+
y: point.pageY - scrollPosition.top
|
|
878
961
|
};
|
|
879
962
|
};
|
|
880
963
|
/** Gets the pointer position on the page, accounting for any position constraints. */
|
|
@@ -970,6 +1053,7 @@ var DragRef = /** @class */ (function () {
|
|
|
970
1053
|
/** Cleans up any cached element dimensions that we don't need after dragging has stopped. */
|
|
971
1054
|
DragRef.prototype._cleanupCachedDimensions = function () {
|
|
972
1055
|
this._boundaryRect = this._previewRect = undefined;
|
|
1056
|
+
this._parentPositions.clear();
|
|
973
1057
|
};
|
|
974
1058
|
/**
|
|
975
1059
|
* Checks whether the element is still inside its boundary after the viewport has been resized.
|
|
@@ -1034,17 +1118,19 @@ var DragRef = /** @class */ (function () {
|
|
|
1034
1118
|
return value ? value.mouse : 0;
|
|
1035
1119
|
};
|
|
1036
1120
|
/** Updates the internal state of the draggable element when scrolling has occurred. */
|
|
1037
|
-
DragRef.prototype._updateOnScroll = function () {
|
|
1038
|
-
var
|
|
1039
|
-
var currentScrollPosition = this._viewportRuler.getViewportScrollPosition();
|
|
1121
|
+
DragRef.prototype._updateOnScroll = function (event) {
|
|
1122
|
+
var scrollDifference = this._parentPositions.handleScroll(event);
|
|
1040
1123
|
// ClientRect dimensions are based on the page's scroll position so
|
|
1041
1124
|
// we have to update the cached boundary ClientRect if the user has scrolled.
|
|
1042
|
-
if (
|
|
1043
|
-
|
|
1044
|
-
var leftDifference = oldScrollPosition.left - currentScrollPosition.left;
|
|
1045
|
-
adjustClientRect(this._boundaryRect, topDifference, leftDifference);
|
|
1125
|
+
if (this._boundaryRect && scrollDifference) {
|
|
1126
|
+
adjustClientRect(this._boundaryRect, scrollDifference.top, scrollDifference.left);
|
|
1046
1127
|
}
|
|
1047
|
-
|
|
1128
|
+
};
|
|
1129
|
+
/** Gets the scroll position of the viewport. */
|
|
1130
|
+
DragRef.prototype._getViewportScrollPosition = function () {
|
|
1131
|
+
var cachedPosition = this._parentPositions.positions.get(this._document);
|
|
1132
|
+
return cachedPosition ? cachedPosition.scrollPosition :
|
|
1133
|
+
this._viewportRuler.getViewportScrollPosition();
|
|
1048
1134
|
};
|
|
1049
1135
|
return DragRef;
|
|
1050
1136
|
}());
|
|
@@ -1128,10 +1214,9 @@ function getRootNode(viewRef, _document) {
|
|
|
1128
1214
|
/**
|
|
1129
1215
|
* Matches the target element's size to the source's size.
|
|
1130
1216
|
* @param target Element that needs to be resized.
|
|
1131
|
-
* @param
|
|
1217
|
+
* @param sourceRect Dimensions of the source element.
|
|
1132
1218
|
*/
|
|
1133
|
-
function matchElementSize(target,
|
|
1134
|
-
var sourceRect = source.getBoundingClientRect();
|
|
1219
|
+
function matchElementSize(target, sourceRect) {
|
|
1135
1220
|
target.style.width = sourceRect.width + "px";
|
|
1136
1221
|
target.style.height = sourceRect.height + "px";
|
|
1137
1222
|
target.style.transform = getTransform(sourceRect.left, sourceRect.top);
|
|
@@ -1261,8 +1346,6 @@ var DropListRef = /** @class */ (function () {
|
|
|
1261
1346
|
this._isDragging = false;
|
|
1262
1347
|
/** Cache of the dimensions of all the items inside the container. */
|
|
1263
1348
|
this._itemPositions = [];
|
|
1264
|
-
/** Cached positions of the scrollable parent elements. */
|
|
1265
|
-
this._parentPositions = new Map();
|
|
1266
1349
|
/**
|
|
1267
1350
|
* Keeps track of the item that was last swapped with the dragged item, as
|
|
1268
1351
|
* well as what direction the pointer was moving in when the swap occured.
|
|
@@ -1311,6 +1394,7 @@ var DropListRef = /** @class */ (function () {
|
|
|
1311
1394
|
this._document = _document;
|
|
1312
1395
|
this.withScrollableParents([this.element]);
|
|
1313
1396
|
_dragDropRegistry.registerDropContainer(this);
|
|
1397
|
+
this._parentPositions = new ParentPositionTracker(_document, _viewportRuler);
|
|
1314
1398
|
}
|
|
1315
1399
|
/** Removes the drop list functionality from the DOM element. */
|
|
1316
1400
|
DropListRef.prototype.dispose = function () {
|
|
@@ -1394,14 +1478,22 @@ var DropListRef = /** @class */ (function () {
|
|
|
1394
1478
|
activeDraggables.splice(newIndex, 0, item);
|
|
1395
1479
|
}
|
|
1396
1480
|
else {
|
|
1397
|
-
coerceElement(this.element)
|
|
1398
|
-
|
|
1481
|
+
var element = coerceElement(this.element);
|
|
1482
|
+
if (this._shouldEnterAsFirstChild(pointerX, pointerY)) {
|
|
1483
|
+
element.insertBefore(placeholder, activeDraggables[0].getRootElement());
|
|
1484
|
+
activeDraggables.unshift(item);
|
|
1485
|
+
}
|
|
1486
|
+
else {
|
|
1487
|
+
element.appendChild(placeholder);
|
|
1488
|
+
activeDraggables.push(item);
|
|
1489
|
+
}
|
|
1399
1490
|
}
|
|
1400
1491
|
// The transform needs to be cleared so it doesn't throw off the measurements.
|
|
1401
1492
|
placeholder.style.transform = '';
|
|
1402
1493
|
// Note that the positions were already cached when we called `start` above,
|
|
1403
|
-
// but we need to refresh them since the amount of items has changed.
|
|
1494
|
+
// but we need to refresh them since the amount of items has changed and also parent rects.
|
|
1404
1495
|
this._cacheItemPositions();
|
|
1496
|
+
this._cacheParentPositions();
|
|
1405
1497
|
this.entered.next({ item: item, container: this, currentIndex: this.getItemIndex(item) });
|
|
1406
1498
|
};
|
|
1407
1499
|
/**
|
|
@@ -1445,10 +1537,19 @@ var DropListRef = /** @class */ (function () {
|
|
|
1445
1537
|
*/
|
|
1446
1538
|
DropListRef.prototype.withItems = function (items) {
|
|
1447
1539
|
var _this = this;
|
|
1540
|
+
var previousItems = this._draggables;
|
|
1448
1541
|
this._draggables = items;
|
|
1449
1542
|
items.forEach(function (item) { return item._withDropContainer(_this); });
|
|
1450
1543
|
if (this.isDragging()) {
|
|
1451
|
-
|
|
1544
|
+
var draggedItems = previousItems.filter(function (item) { return item.isDragging(); });
|
|
1545
|
+
// If all of the items being dragged were removed
|
|
1546
|
+
// from the list, abort the current drag sequence.
|
|
1547
|
+
if (draggedItems.every(function (item) { return items.indexOf(item) === -1; })) {
|
|
1548
|
+
this._reset();
|
|
1549
|
+
}
|
|
1550
|
+
else {
|
|
1551
|
+
this._cacheItems();
|
|
1552
|
+
}
|
|
1452
1553
|
}
|
|
1453
1554
|
return this;
|
|
1454
1555
|
};
|
|
@@ -1486,6 +1587,10 @@ var DropListRef = /** @class */ (function () {
|
|
|
1486
1587
|
elements.indexOf(element) === -1 ? __spread([element], elements) : elements.slice();
|
|
1487
1588
|
return this;
|
|
1488
1589
|
};
|
|
1590
|
+
/** Gets the scrollable parents that are registered with this drop container. */
|
|
1591
|
+
DropListRef.prototype.getScrollableParents = function () {
|
|
1592
|
+
return this._scrollableElements;
|
|
1593
|
+
};
|
|
1489
1594
|
/**
|
|
1490
1595
|
* Figures out the index of an item in the container.
|
|
1491
1596
|
* @param item Item whose index should be determined.
|
|
@@ -1591,7 +1696,7 @@ var DropListRef = /** @class */ (function () {
|
|
|
1591
1696
|
var verticalScrollDirection = 0 /* NONE */;
|
|
1592
1697
|
var horizontalScrollDirection = 0 /* NONE */;
|
|
1593
1698
|
// Check whether we should start scrolling any of the parent containers.
|
|
1594
|
-
this._parentPositions.forEach(function (position, element) {
|
|
1699
|
+
this._parentPositions.positions.forEach(function (position, element) {
|
|
1595
1700
|
var _a;
|
|
1596
1701
|
// We have special handling for the `document` below. Also this would be
|
|
1597
1702
|
// nicer with a for...of loop, but it requires changing a compiler flag.
|
|
@@ -1633,24 +1738,11 @@ var DropListRef = /** @class */ (function () {
|
|
|
1633
1738
|
};
|
|
1634
1739
|
/** Caches the positions of the configured scrollable parents. */
|
|
1635
1740
|
DropListRef.prototype._cacheParentPositions = function () {
|
|
1636
|
-
var
|
|
1637
|
-
this._parentPositions.
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
this._scrollableElements.forEach(function (element) {
|
|
1642
|
-
var clientRect = getMutableClientRect(element);
|
|
1643
|
-
// We keep the ClientRect cached in two properties, because it's referenced in a lot of
|
|
1644
|
-
// performance-sensitive places and we want to avoid the extra lookups. The `element` is
|
|
1645
|
-
// guaranteed to always be in the `_scrollableElements` so this should always match.
|
|
1646
|
-
if (element === _this.element) {
|
|
1647
|
-
_this._clientRect = clientRect;
|
|
1648
|
-
}
|
|
1649
|
-
_this._parentPositions.set(element, {
|
|
1650
|
-
scrollPosition: { top: element.scrollTop, left: element.scrollLeft },
|
|
1651
|
-
clientRect: clientRect
|
|
1652
|
-
});
|
|
1653
|
-
});
|
|
1741
|
+
var element = coerceElement(this.element);
|
|
1742
|
+
this._parentPositions.cache(this._scrollableElements);
|
|
1743
|
+
// The list element is always in the `scrollableElements`
|
|
1744
|
+
// so we can take advantage of the cached `ClientRect`.
|
|
1745
|
+
this._clientRect = this._parentPositions.positions.get(element).clientRect;
|
|
1654
1746
|
};
|
|
1655
1747
|
/** Refreshes the position cache of the items and sibling containers. */
|
|
1656
1748
|
DropListRef.prototype._cacheItemPositions = function () {
|
|
@@ -1670,7 +1762,12 @@ var DropListRef = /** @class */ (function () {
|
|
|
1670
1762
|
var styles = coerceElement(this.element).style;
|
|
1671
1763
|
styles.scrollSnapType = styles.msScrollSnapType = this._initialScrollSnap;
|
|
1672
1764
|
// TODO(crisbeto): may have to wait for the animations to finish.
|
|
1673
|
-
this._activeDraggables.forEach(function (item) {
|
|
1765
|
+
this._activeDraggables.forEach(function (item) {
|
|
1766
|
+
var rootElement = item.getRootElement();
|
|
1767
|
+
if (rootElement) {
|
|
1768
|
+
rootElement.style.transform = '';
|
|
1769
|
+
}
|
|
1770
|
+
});
|
|
1674
1771
|
this._siblings.forEach(function (sibling) { return sibling._stopReceiving(_this); });
|
|
1675
1772
|
this._activeDraggables = [];
|
|
1676
1773
|
this._itemPositions = [];
|
|
@@ -1724,6 +1821,29 @@ var DropListRef = /** @class */ (function () {
|
|
|
1724
1821
|
}
|
|
1725
1822
|
return itemOffset;
|
|
1726
1823
|
};
|
|
1824
|
+
/**
|
|
1825
|
+
* Checks if pointer is entering in the first position
|
|
1826
|
+
* @param pointerX Position of the user's pointer along the X axis.
|
|
1827
|
+
* @param pointerY Position of the user's pointer along the Y axis.
|
|
1828
|
+
*/
|
|
1829
|
+
DropListRef.prototype._shouldEnterAsFirstChild = function (pointerX, pointerY) {
|
|
1830
|
+
if (!this._activeDraggables.length) {
|
|
1831
|
+
return false;
|
|
1832
|
+
}
|
|
1833
|
+
var itemPositions = this._itemPositions;
|
|
1834
|
+
var isHorizontal = this._orientation === 'horizontal';
|
|
1835
|
+
// `itemPositions` are sorted by position while `activeDraggables` are sorted by child index
|
|
1836
|
+
// check if container is using some sort of "reverse" ordering (eg: flex-direction: row-reverse)
|
|
1837
|
+
var reversed = itemPositions[0].drag !== this._activeDraggables[0];
|
|
1838
|
+
if (reversed) {
|
|
1839
|
+
var lastItemRect = itemPositions[itemPositions.length - 1].clientRect;
|
|
1840
|
+
return isHorizontal ? pointerX >= lastItemRect.right : pointerY >= lastItemRect.bottom;
|
|
1841
|
+
}
|
|
1842
|
+
else {
|
|
1843
|
+
var firstItemRect = itemPositions[0].clientRect;
|
|
1844
|
+
return isHorizontal ? pointerX <= firstItemRect.left : pointerY <= firstItemRect.top;
|
|
1845
|
+
}
|
|
1846
|
+
};
|
|
1727
1847
|
/**
|
|
1728
1848
|
* Gets the index of an item in the drop container, based on the position of the user's pointer.
|
|
1729
1849
|
* @param item Item that is being sorted.
|
|
@@ -1752,8 +1872,8 @@ var DropListRef = /** @class */ (function () {
|
|
|
1752
1872
|
return isHorizontal ?
|
|
1753
1873
|
// Round these down since most browsers report client rects with
|
|
1754
1874
|
// sub-pixel precision, whereas the pointer coordinates are rounded to pixels.
|
|
1755
|
-
pointerX >= Math.floor(clientRect.left) && pointerX
|
|
1756
|
-
pointerY >= Math.floor(clientRect.top) && pointerY
|
|
1875
|
+
pointerX >= Math.floor(clientRect.left) && pointerX < Math.floor(clientRect.right) :
|
|
1876
|
+
pointerY >= Math.floor(clientRect.top) && pointerY < Math.floor(clientRect.bottom);
|
|
1757
1877
|
});
|
|
1758
1878
|
};
|
|
1759
1879
|
/** Caches the current items in the list and their positions. */
|
|
@@ -1762,48 +1882,6 @@ var DropListRef = /** @class */ (function () {
|
|
|
1762
1882
|
this._cacheItemPositions();
|
|
1763
1883
|
this._cacheParentPositions();
|
|
1764
1884
|
};
|
|
1765
|
-
/**
|
|
1766
|
-
* Updates the internal state of the container after a scroll event has happened.
|
|
1767
|
-
* @param scrolledParent Element that was scrolled.
|
|
1768
|
-
* @param newTop New top scroll position.
|
|
1769
|
-
* @param newLeft New left scroll position.
|
|
1770
|
-
*/
|
|
1771
|
-
DropListRef.prototype._updateAfterScroll = function (scrolledParent, newTop, newLeft) {
|
|
1772
|
-
var _this = this;
|
|
1773
|
-
// Used when figuring out whether an element is inside the scroll parent. If the scrolled
|
|
1774
|
-
// parent is the `document`, we use the `documentElement`, because IE doesn't support `contains`
|
|
1775
|
-
// on the `document`.
|
|
1776
|
-
var scrolledParentNode = scrolledParent === this._document ? scrolledParent.documentElement : scrolledParent;
|
|
1777
|
-
var scrollPosition = this._parentPositions.get(scrolledParent).scrollPosition;
|
|
1778
|
-
var topDifference = scrollPosition.top - newTop;
|
|
1779
|
-
var leftDifference = scrollPosition.left - newLeft;
|
|
1780
|
-
// Go through and update the cached positions of the scroll
|
|
1781
|
-
// parents that are inside the element that was scrolled.
|
|
1782
|
-
this._parentPositions.forEach(function (position, node) {
|
|
1783
|
-
if (position.clientRect && scrolledParent !== node && scrolledParentNode.contains(node)) {
|
|
1784
|
-
adjustClientRect(position.clientRect, topDifference, leftDifference);
|
|
1785
|
-
}
|
|
1786
|
-
});
|
|
1787
|
-
// Since we know the amount that the user has scrolled we can shift all of the client rectangles
|
|
1788
|
-
// ourselves. This is cheaper than re-measuring everything and we can avoid inconsistent
|
|
1789
|
-
// behavior where we might be measuring the element before its position has changed.
|
|
1790
|
-
this._itemPositions.forEach(function (_a) {
|
|
1791
|
-
var clientRect = _a.clientRect;
|
|
1792
|
-
adjustClientRect(clientRect, topDifference, leftDifference);
|
|
1793
|
-
});
|
|
1794
|
-
// We need two loops for this, because we want all of the cached
|
|
1795
|
-
// positions to be up-to-date before we re-sort the item.
|
|
1796
|
-
this._itemPositions.forEach(function (_a) {
|
|
1797
|
-
var drag = _a.drag;
|
|
1798
|
-
if (_this._dragDropRegistry.isDragging(drag)) {
|
|
1799
|
-
// We need to re-sort the item manually, because the pointer move
|
|
1800
|
-
// events won't be dispatched while the user is scrolling.
|
|
1801
|
-
drag._sortFromLastPointerPosition();
|
|
1802
|
-
}
|
|
1803
|
-
});
|
|
1804
|
-
scrollPosition.top = newTop;
|
|
1805
|
-
scrollPosition.left = newLeft;
|
|
1806
|
-
};
|
|
1807
1885
|
/**
|
|
1808
1886
|
* Checks whether the user's pointer is positioned over the container.
|
|
1809
1887
|
* @param x Pointer position along the X axis.
|
|
@@ -1875,21 +1953,26 @@ var DropListRef = /** @class */ (function () {
|
|
|
1875
1953
|
var _this = this;
|
|
1876
1954
|
this._viewportScrollSubscription = this._dragDropRegistry.scroll.subscribe(function (event) {
|
|
1877
1955
|
if (_this.isDragging()) {
|
|
1878
|
-
var
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
}
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1956
|
+
var scrollDifference_1 = _this._parentPositions.handleScroll(event);
|
|
1957
|
+
if (scrollDifference_1) {
|
|
1958
|
+
// Since we know the amount that the user has scrolled we can shift all of the
|
|
1959
|
+
// client rectangles ourselves. This is cheaper than re-measuring everything and
|
|
1960
|
+
// we can avoid inconsistent behavior where we might be measuring the element before
|
|
1961
|
+
// its position has changed.
|
|
1962
|
+
_this._itemPositions.forEach(function (_a) {
|
|
1963
|
+
var clientRect = _a.clientRect;
|
|
1964
|
+
adjustClientRect(clientRect, scrollDifference_1.top, scrollDifference_1.left);
|
|
1965
|
+
});
|
|
1966
|
+
// We need two loops for this, because we want all of the cached
|
|
1967
|
+
// positions to be up-to-date before we re-sort the item.
|
|
1968
|
+
_this._itemPositions.forEach(function (_a) {
|
|
1969
|
+
var drag = _a.drag;
|
|
1970
|
+
if (_this._dragDropRegistry.isDragging(drag)) {
|
|
1971
|
+
// We need to re-sort the item manually, because the pointer move
|
|
1972
|
+
// events won't be dispatched while the user is scrolling.
|
|
1973
|
+
drag._sortFromLastPointerPosition();
|
|
1974
|
+
}
|
|
1975
|
+
});
|
|
1893
1976
|
}
|
|
1894
1977
|
}
|
|
1895
1978
|
else if (_this.isReceiving()) {
|
|
@@ -3160,6 +3243,7 @@ var DragDropModule = /** @class */ (function () {
|
|
|
3160
3243
|
CdkDragPlaceholder,
|
|
3161
3244
|
],
|
|
3162
3245
|
exports: [
|
|
3246
|
+
CdkScrollableModule,
|
|
3163
3247
|
CdkDropList,
|
|
3164
3248
|
CdkDropListGroup,
|
|
3165
3249
|
CdkDrag,
|