@angular/cdk 9.1.3 → 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 +43 -4
- 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 +140 -90
- package/bundles/cdk-a11y.umd.js.map +1 -1
- package/bundles/cdk-a11y.umd.min.js +14 -7
- package/bundles/cdk-a11y.umd.min.js.map +1 -1
- package/bundles/cdk-coercion.umd.js +0 -1
- package/bundles/cdk-coercion.umd.js.map +1 -1
- package/bundles/cdk-coercion.umd.min.js.map +1 -1
- package/bundles/cdk-drag-drop.umd.js +292 -179
- package/bundles/cdk-drag-drop.umd.js.map +1 -1
- package/bundles/cdk-drag-drop.umd.min.js +23 -9
- 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-table.umd.js +58 -27
- package/bundles/cdk-table.umd.js.map +1 -1
- package/bundles/cdk-table.umd.min.js +12 -5
- package/bundles/cdk-table.umd.min.js.map +1 -1
- package/bundles/cdk-testing-protractor.umd.js +15 -9
- package/bundles/cdk-testing-protractor.umd.js.map +1 -1
- package/bundles/cdk-testing-protractor.umd.min.js +2 -2
- package/bundles/cdk-testing-protractor.umd.min.js.map +1 -1
- package/bundles/cdk-testing-testbed.umd.js +77 -19
- package/bundles/cdk-testing-testbed.umd.js.map +1 -1
- package/bundles/cdk-testing-testbed.umd.min.js +8 -8
- package/bundles/cdk-testing-testbed.umd.min.js.map +1 -1
- package/bundles/cdk-tree.umd.js +9 -4
- 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/coercion/array.d.ts +1 -0
- package/drag-drop/client-rect.d.ts +31 -0
- package/drag-drop/directives/config.d.ts +1 -0
- package/drag-drop/directives/drop-list.d.ts +4 -3
- package/drag-drop/drag-ref.d.ts +8 -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 +198 -92
- package/esm2015/a11y/focus-trap/configurable-focus-trap-factory.js +3 -3
- package/esm2015/a11y/focus-trap/focus-trap.js +1 -1
- package/esm2015/a11y/high-contrast-mode/high-contrast-mode-detector.js +10 -6
- package/esm2015/a11y/live-announcer/live-announcer.js +1 -1
- package/esm2015/a11y/public-api.js +2 -2
- package/esm2015/coercion/array.js +1 -2
- package/esm2015/drag-drop/client-rect.js +75 -0
- package/esm2015/drag-drop/directives/config.js +3 -1
- package/esm2015/drag-drop/directives/drag.js +3 -2
- package/esm2015/drag-drop/directives/drop-list.js +24 -18
- package/esm2015/drag-drop/drag-drop-module.js +3 -1
- package/esm2015/drag-drop/drag-ref.js +97 -43
- package/esm2015/drag-drop/drop-list-ref.js +119 -187
- 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/table/cell.js +18 -8
- package/esm2015/table/public-api.js +3 -2
- package/esm2015/table/row.js +24 -8
- package/esm2015/table/table.js +26 -12
- package/esm2015/table/text-column.js +3 -26
- package/esm2015/table/tokens.js +44 -0
- package/esm2015/testing/protractor/protractor-harness-environment.js +13 -8
- 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/testbed-harness-environment.js +16 -10
- package/esm2015/testing/testbed/unit-test-element.js +13 -2
- package/esm2015/tree/padding.js +9 -10
- 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 +112 -65
- package/esm5/a11y/high-contrast-mode/high-contrast-mode-detector.js +9 -6
- package/esm5/coercion/array.js +1 -2
- package/esm5/drag-drop/client-rect.js +60 -0
- package/esm5/drag-drop/directives/config.js +1 -1
- package/esm5/drag-drop/directives/drag.js +3 -2
- package/esm5/drag-drop/directives/drop-list.js +13 -10
- package/esm5/drag-drop/drag-drop-module.js +3 -1
- package/esm5/drag-drop/drag-ref.js +62 -33
- package/esm5/drag-drop/drop-list-ref.js +89 -139
- 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/table/cell.js +13 -8
- package/esm5/table/public-api.js +2 -1
- package/esm5/table/row.js +21 -11
- package/esm5/table/table.js +16 -11
- package/esm5/table/text-column.js +3 -4
- package/esm5/table/tokens.js +16 -0
- package/esm5/testing/protractor/protractor-harness-environment.js +17 -11
- 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/testbed-harness-environment.js +17 -11
- package/esm5/testing/testbed/unit-test-element.js +10 -3
- package/esm5/tree/padding.js +9 -5
- package/esm5/tree/tree.js +2 -1
- package/esm5/version.js +1 -1
- package/fesm2015/a11y.js +234 -126
- package/fesm2015/a11y.js.map +1 -1
- package/fesm2015/cdk.js +1 -1
- package/fesm2015/cdk.js.map +1 -1
- package/fesm2015/coercion.js +0 -1
- package/fesm2015/coercion.js.map +1 -1
- package/fesm2015/drag-drop.js +448 -247
- 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/table.js +98 -49
- package/fesm2015/table.js.map +1 -1
- package/fesm2015/testing/protractor.js +13 -8
- package/fesm2015/testing/protractor.js.map +1 -1
- package/fesm2015/testing/testbed.js +71 -13
- package/fesm2015/testing/testbed.js.map +1 -1
- package/fesm2015/tree.js +9 -9
- package/fesm2015/tree.js.map +1 -1
- package/fesm5/a11y.js +141 -92
- package/fesm5/a11y.js.map +1 -1
- package/fesm5/cdk.js +1 -1
- package/fesm5/cdk.js.map +1 -1
- package/fesm5/coercion.js +0 -1
- package/fesm5/coercion.js.map +1 -1
- package/fesm5/drag-drop.js +294 -181
- 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/table.js +59 -29
- package/fesm5/table.js.map +1 -1
- package/fesm5/testing/protractor.js +17 -11
- package/fesm5/testing/protractor.js.map +1 -1
- package/fesm5/testing/testbed.js +78 -20
- package/fesm5/testing/testbed.js.map +1 -1
- package/fesm5/tree.js +9 -4
- 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/schematics/utils/ast/ng-module-imports.js +3 -2
- package/scrolling/index.metadata.json +1 -1
- package/scrolling/scrolling-module.d.ts +2 -0
- package/table/cell.d.ts +2 -0
- package/table/index.metadata.json +1 -1
- package/table/public-api.d.ts +1 -0
- package/table/row.d.ts +6 -3
- package/table/table.d.ts +2 -0
- package/table/text-column.d.ts +2 -13
- package/table/tokens.d.ts +25 -0
- package/testing/protractor/protractor-harness-environment.d.ts +10 -3
- package/testing/testbed/fake-events/dispatch-events.d.ts +8 -3
- package/testing/testbed/fake-events/event-objects.d.ts +12 -1
- package/testing/testbed/testbed-harness-environment.d.ts +12 -4
- package/tree/index.metadata.json +1 -1
- package/tree/padding.d.ts +6 -2
- 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 -96
- 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/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
|
/**
|
|
@@ -82,6 +82,138 @@ function parseCssPropertyValue(computedStyle, name) {
|
|
|
82
82
|
return value.split(',').map(function (part) { return part.trim(); });
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
/**
|
|
86
|
+
* @license
|
|
87
|
+
* Copyright Google LLC All Rights Reserved.
|
|
88
|
+
*
|
|
89
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
90
|
+
* found in the LICENSE file at https://angular.io/license
|
|
91
|
+
*/
|
|
92
|
+
/** Gets a mutable version of an element's bounding `ClientRect`. */
|
|
93
|
+
function getMutableClientRect(element) {
|
|
94
|
+
var clientRect = element.getBoundingClientRect();
|
|
95
|
+
// We need to clone the `clientRect` here, because all the values on it are readonly
|
|
96
|
+
// and we need to be able to update them. Also we can't use a spread here, because
|
|
97
|
+
// the values on a `ClientRect` aren't own properties. See:
|
|
98
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect#Notes
|
|
99
|
+
return {
|
|
100
|
+
top: clientRect.top,
|
|
101
|
+
right: clientRect.right,
|
|
102
|
+
bottom: clientRect.bottom,
|
|
103
|
+
left: clientRect.left,
|
|
104
|
+
width: clientRect.width,
|
|
105
|
+
height: clientRect.height
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Checks whether some coordinates are within a `ClientRect`.
|
|
110
|
+
* @param clientRect ClientRect that is being checked.
|
|
111
|
+
* @param x Coordinates along the X axis.
|
|
112
|
+
* @param y Coordinates along the Y axis.
|
|
113
|
+
*/
|
|
114
|
+
function isInsideClientRect(clientRect, x, y) {
|
|
115
|
+
var top = clientRect.top, bottom = clientRect.bottom, left = clientRect.left, right = clientRect.right;
|
|
116
|
+
return y >= top && y <= bottom && x >= left && x <= right;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Updates the top/left positions of a `ClientRect`, as well as their bottom/right counterparts.
|
|
120
|
+
* @param clientRect `ClientRect` that should be updated.
|
|
121
|
+
* @param top Amount to add to the `top` position.
|
|
122
|
+
* @param left Amount to add to the `left` position.
|
|
123
|
+
*/
|
|
124
|
+
function adjustClientRect(clientRect, top, left) {
|
|
125
|
+
clientRect.top += top;
|
|
126
|
+
clientRect.bottom = clientRect.top + clientRect.height;
|
|
127
|
+
clientRect.left += left;
|
|
128
|
+
clientRect.right = clientRect.left + clientRect.width;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Checks whether the pointer coordinates are close to a ClientRect.
|
|
132
|
+
* @param rect ClientRect to check against.
|
|
133
|
+
* @param threshold Threshold around the ClientRect.
|
|
134
|
+
* @param pointerX Coordinates along the X axis.
|
|
135
|
+
* @param pointerY Coordinates along the Y axis.
|
|
136
|
+
*/
|
|
137
|
+
function isPointerNearClientRect(rect, threshold, pointerX, pointerY) {
|
|
138
|
+
var top = rect.top, right = rect.right, bottom = rect.bottom, left = rect.left, width = rect.width, height = rect.height;
|
|
139
|
+
var xThreshold = width * threshold;
|
|
140
|
+
var yThreshold = height * threshold;
|
|
141
|
+
return pointerY > top - yThreshold && pointerY < bottom + yThreshold &&
|
|
142
|
+
pointerX > left - xThreshold && pointerX < right + xThreshold;
|
|
143
|
+
}
|
|
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
|
+
|
|
85
217
|
/**
|
|
86
218
|
* @license
|
|
87
219
|
* Copyright Google LLC All Rights Reserved.
|
|
@@ -187,8 +319,8 @@ var DragRef = /** @class */ (function () {
|
|
|
187
319
|
// Prevent the default action as early as possible in order to block
|
|
188
320
|
// native actions like dragging the selected text or images with the mouse.
|
|
189
321
|
event.preventDefault();
|
|
322
|
+
var pointerPosition = _this._getPointerPositionOnPage(event);
|
|
190
323
|
if (!_this._hasStartedDragging) {
|
|
191
|
-
var pointerPosition = _this._getPointerPositionOnPage(event);
|
|
192
324
|
var distanceX = Math.abs(pointerPosition.x - _this._pickupPositionOnPage.x);
|
|
193
325
|
var distanceY = Math.abs(pointerPosition.y - _this._pickupPositionOnPage.y);
|
|
194
326
|
var isOverThreshold = distanceX + distanceY >= _this._config.dragStartThreshold;
|
|
@@ -220,7 +352,7 @@ var DragRef = /** @class */ (function () {
|
|
|
220
352
|
_this._previewRect = (_this._preview || _this._rootElement).getBoundingClientRect();
|
|
221
353
|
}
|
|
222
354
|
}
|
|
223
|
-
var constrainedPointerPosition = _this._getConstrainedPointerPosition(
|
|
355
|
+
var constrainedPointerPosition = _this._getConstrainedPointerPosition(pointerPosition);
|
|
224
356
|
_this._hasMoved = true;
|
|
225
357
|
_this._updatePointerDirectionDelta(constrainedPointerPosition);
|
|
226
358
|
if (_this._dropContainer) {
|
|
@@ -259,6 +391,7 @@ var DragRef = /** @class */ (function () {
|
|
|
259
391
|
_this._endDragSequence(event);
|
|
260
392
|
};
|
|
261
393
|
this.withRootElement(element);
|
|
394
|
+
this._parentPositions = new ParentPositionTracker(_document, _viewportRuler);
|
|
262
395
|
_dragDropRegistry.registerDragItem(this);
|
|
263
396
|
}
|
|
264
397
|
Object.defineProperty(DragRef.prototype, "disabled", {
|
|
@@ -323,13 +456,16 @@ var DragRef = /** @class */ (function () {
|
|
|
323
456
|
* dragging on an element that you might not have access to.
|
|
324
457
|
*/
|
|
325
458
|
DragRef.prototype.withRootElement = function (rootElement) {
|
|
459
|
+
var _this = this;
|
|
326
460
|
var element = coerceElement(rootElement);
|
|
327
461
|
if (element !== this._rootElement) {
|
|
328
462
|
if (this._rootElement) {
|
|
329
463
|
this._removeRootElementListeners(this._rootElement);
|
|
330
464
|
}
|
|
331
|
-
|
|
332
|
-
|
|
465
|
+
this._ngZone.runOutsideAngular(function () {
|
|
466
|
+
element.addEventListener('mousedown', _this._pointerDown, activeEventListenerOptions);
|
|
467
|
+
element.addEventListener('touchstart', _this._pointerDown, passiveEventListenerOptions);
|
|
468
|
+
});
|
|
333
469
|
this._initialTransform = undefined;
|
|
334
470
|
this._rootElement = element;
|
|
335
471
|
}
|
|
@@ -376,6 +512,7 @@ var DragRef = /** @class */ (function () {
|
|
|
376
512
|
this._disabledHandles.clear();
|
|
377
513
|
this._dropContainer = undefined;
|
|
378
514
|
this._resizeSubscription.unsubscribe();
|
|
515
|
+
this._parentPositions.clear();
|
|
379
516
|
this._boundaryElement = this._rootElement = this._placeholderTemplate =
|
|
380
517
|
this._previewTemplate = this._anchor = null;
|
|
381
518
|
};
|
|
@@ -438,7 +575,7 @@ var DragRef = /** @class */ (function () {
|
|
|
438
575
|
DragRef.prototype._sortFromLastPointerPosition = function () {
|
|
439
576
|
var position = this._pointerPositionAtLastDirectionChange;
|
|
440
577
|
if (position && this._dropContainer) {
|
|
441
|
-
this._updateActiveDropContainer(position);
|
|
578
|
+
this._updateActiveDropContainer(this._getConstrainedPointerPosition(position));
|
|
442
579
|
}
|
|
443
580
|
};
|
|
444
581
|
/** Unsubscribes from the global subscriptions. */
|
|
@@ -523,7 +660,8 @@ var DragRef = /** @class */ (function () {
|
|
|
523
660
|
this._lastTouchEventTime = Date.now();
|
|
524
661
|
}
|
|
525
662
|
this._toggleNativeDragInteractions();
|
|
526
|
-
|
|
663
|
+
var dropContainer = this._dropContainer;
|
|
664
|
+
if (dropContainer) {
|
|
527
665
|
var element = this._rootElement;
|
|
528
666
|
var parent_1 = element.parentNode;
|
|
529
667
|
var preview = this._preview = this._createPreviewElement();
|
|
@@ -537,13 +675,16 @@ var DragRef = /** @class */ (function () {
|
|
|
537
675
|
element.style.display = 'none';
|
|
538
676
|
this._document.body.appendChild(parent_1.replaceChild(placeholder, element));
|
|
539
677
|
getPreviewInsertionPoint(this._document).appendChild(preview);
|
|
540
|
-
|
|
541
|
-
this._initialContainer =
|
|
542
|
-
this._initialIndex =
|
|
678
|
+
dropContainer.start();
|
|
679
|
+
this._initialContainer = dropContainer;
|
|
680
|
+
this._initialIndex = dropContainer.getItemIndex(this);
|
|
543
681
|
}
|
|
544
682
|
else {
|
|
545
683
|
this._initialContainer = this._initialIndex = undefined;
|
|
546
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() : []);
|
|
547
688
|
};
|
|
548
689
|
/**
|
|
549
690
|
* Sets up the different variables and subscriptions
|
|
@@ -589,11 +730,11 @@ var DragRef = /** @class */ (function () {
|
|
|
589
730
|
this._removeSubscriptions();
|
|
590
731
|
this._pointerMoveSubscription = this._dragDropRegistry.pointerMove.subscribe(this._pointerMove);
|
|
591
732
|
this._pointerUpSubscription = this._dragDropRegistry.pointerUp.subscribe(this._pointerUp);
|
|
592
|
-
this._scrollSubscription = this._dragDropRegistry.scroll.
|
|
593
|
-
_this.
|
|
733
|
+
this._scrollSubscription = this._dragDropRegistry.scroll.subscribe(function (scrollEvent) {
|
|
734
|
+
_this._updateOnScroll(scrollEvent);
|
|
594
735
|
});
|
|
595
736
|
if (this._boundaryElement) {
|
|
596
|
-
this._boundaryRect = this._boundaryElement
|
|
737
|
+
this._boundaryRect = getMutableClientRect(this._boundaryElement);
|
|
597
738
|
}
|
|
598
739
|
// If we have a custom preview we can't know ahead of time how large it'll be so we position
|
|
599
740
|
// it next to the cursor. The exception is when the consumer has opted into making the preview
|
|
@@ -690,13 +831,16 @@ var DragRef = /** @class */ (function () {
|
|
|
690
831
|
var previewClass = this.previewClass;
|
|
691
832
|
var previewTemplate = previewConfig ? previewConfig.template : null;
|
|
692
833
|
var preview;
|
|
693
|
-
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;
|
|
694
838
|
var viewRef = previewConfig.viewContainer.createEmbeddedView(previewTemplate, previewConfig.context);
|
|
695
839
|
viewRef.detectChanges();
|
|
696
840
|
preview = getRootNode(viewRef, this._document);
|
|
697
841
|
this._previewRef = viewRef;
|
|
698
842
|
if (previewConfig.matchSize) {
|
|
699
|
-
matchElementSize(preview,
|
|
843
|
+
matchElementSize(preview, rootRect);
|
|
700
844
|
}
|
|
701
845
|
else {
|
|
702
846
|
preview.style.transform =
|
|
@@ -706,7 +850,7 @@ var DragRef = /** @class */ (function () {
|
|
|
706
850
|
else {
|
|
707
851
|
var element = this._rootElement;
|
|
708
852
|
preview = deepCloneNode(element);
|
|
709
|
-
matchElementSize(preview, element);
|
|
853
|
+
matchElementSize(preview, element.getBoundingClientRect());
|
|
710
854
|
}
|
|
711
855
|
extendStyles(preview.style, {
|
|
712
856
|
// It's important that we disable the pointer events on the preview, because
|
|
@@ -717,7 +861,7 @@ var DragRef = /** @class */ (function () {
|
|
|
717
861
|
position: 'fixed',
|
|
718
862
|
top: '0',
|
|
719
863
|
left: '0',
|
|
720
|
-
zIndex:
|
|
864
|
+
zIndex: "" + (this._config.zIndex || 1000)
|
|
721
865
|
});
|
|
722
866
|
toggleNativeDragInteractions(preview, false);
|
|
723
867
|
preview.classList.add('cdk-drag-preview');
|
|
@@ -798,8 +942,9 @@ var DragRef = /** @class */ (function () {
|
|
|
798
942
|
var handleElement = referenceElement === this._rootElement ? null : referenceElement;
|
|
799
943
|
var referenceRect = handleElement ? handleElement.getBoundingClientRect() : elementRect;
|
|
800
944
|
var point = isTouchEvent(event) ? event.targetTouches[0] : event;
|
|
801
|
-
var
|
|
802
|
-
var
|
|
945
|
+
var scrollPosition = this._getViewportScrollPosition();
|
|
946
|
+
var x = point.pageX - referenceRect.left - scrollPosition.left;
|
|
947
|
+
var y = point.pageY - referenceRect.top - scrollPosition.top;
|
|
803
948
|
return {
|
|
804
949
|
x: referenceRect.left - elementRect.left + x,
|
|
805
950
|
y: referenceRect.top - elementRect.top + y
|
|
@@ -809,14 +954,14 @@ var DragRef = /** @class */ (function () {
|
|
|
809
954
|
DragRef.prototype._getPointerPositionOnPage = function (event) {
|
|
810
955
|
// `touches` will be empty for start/end events so we have to fall back to `changedTouches`.
|
|
811
956
|
var point = isTouchEvent(event) ? (event.touches[0] || event.changedTouches[0]) : event;
|
|
957
|
+
var scrollPosition = this._getViewportScrollPosition();
|
|
812
958
|
return {
|
|
813
|
-
x: point.pageX -
|
|
814
|
-
y: point.pageY -
|
|
959
|
+
x: point.pageX - scrollPosition.left,
|
|
960
|
+
y: point.pageY - scrollPosition.top
|
|
815
961
|
};
|
|
816
962
|
};
|
|
817
963
|
/** Gets the pointer position on the page, accounting for any position constraints. */
|
|
818
|
-
DragRef.prototype._getConstrainedPointerPosition = function (
|
|
819
|
-
var point = this._getPointerPositionOnPage(event);
|
|
964
|
+
DragRef.prototype._getConstrainedPointerPosition = function (point) {
|
|
820
965
|
var constrainedPoint = this.constrainPosition ? this.constrainPosition(point, this) : point;
|
|
821
966
|
var dropContainerLock = this._dropContainer ? this._dropContainer.lockAxis : null;
|
|
822
967
|
if (this.lockAxis === 'x' || dropContainerLock === 'x') {
|
|
@@ -908,6 +1053,7 @@ var DragRef = /** @class */ (function () {
|
|
|
908
1053
|
/** Cleans up any cached element dimensions that we don't need after dragging has stopped. */
|
|
909
1054
|
DragRef.prototype._cleanupCachedDimensions = function () {
|
|
910
1055
|
this._boundaryRect = this._previewRect = undefined;
|
|
1056
|
+
this._parentPositions.clear();
|
|
911
1057
|
};
|
|
912
1058
|
/**
|
|
913
1059
|
* Checks whether the element is still inside its boundary after the viewport has been resized.
|
|
@@ -971,6 +1117,21 @@ var DragRef = /** @class */ (function () {
|
|
|
971
1117
|
}
|
|
972
1118
|
return value ? value.mouse : 0;
|
|
973
1119
|
};
|
|
1120
|
+
/** Updates the internal state of the draggable element when scrolling has occurred. */
|
|
1121
|
+
DragRef.prototype._updateOnScroll = function (event) {
|
|
1122
|
+
var scrollDifference = this._parentPositions.handleScroll(event);
|
|
1123
|
+
// ClientRect dimensions are based on the page's scroll position so
|
|
1124
|
+
// we have to update the cached boundary ClientRect if the user has scrolled.
|
|
1125
|
+
if (this._boundaryRect && scrollDifference) {
|
|
1126
|
+
adjustClientRect(this._boundaryRect, scrollDifference.top, scrollDifference.left);
|
|
1127
|
+
}
|
|
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();
|
|
1134
|
+
};
|
|
974
1135
|
return DragRef;
|
|
975
1136
|
}());
|
|
976
1137
|
/**
|
|
@@ -1042,21 +1203,20 @@ function getPreviewInsertionPoint(documentRef) {
|
|
|
1042
1203
|
* If the root is not an HTML element it gets wrapped in one.
|
|
1043
1204
|
*/
|
|
1044
1205
|
function getRootNode(viewRef, _document) {
|
|
1045
|
-
var
|
|
1046
|
-
if (
|
|
1047
|
-
|
|
1048
|
-
wrapper.appendChild(rootNode);
|
|
1049
|
-
return wrapper;
|
|
1206
|
+
var rootNodes = viewRef.rootNodes;
|
|
1207
|
+
if (rootNodes.length === 1 && rootNodes[0].nodeType === _document.ELEMENT_NODE) {
|
|
1208
|
+
return rootNodes[0];
|
|
1050
1209
|
}
|
|
1051
|
-
|
|
1210
|
+
var wrapper = _document.createElement('div');
|
|
1211
|
+
rootNodes.forEach(function (node) { return wrapper.appendChild(node); });
|
|
1212
|
+
return wrapper;
|
|
1052
1213
|
}
|
|
1053
1214
|
/**
|
|
1054
1215
|
* Matches the target element's size to the source's size.
|
|
1055
1216
|
* @param target Element that needs to be resized.
|
|
1056
|
-
* @param
|
|
1217
|
+
* @param sourceRect Dimensions of the source element.
|
|
1057
1218
|
*/
|
|
1058
|
-
function matchElementSize(target,
|
|
1059
|
-
var sourceRect = source.getBoundingClientRect();
|
|
1219
|
+
function matchElementSize(target, sourceRect) {
|
|
1060
1220
|
target.style.width = sourceRect.width + "px";
|
|
1061
1221
|
target.style.height = sourceRect.height + "px";
|
|
1062
1222
|
target.style.transform = getTransform(sourceRect.left, sourceRect.top);
|
|
@@ -1186,8 +1346,6 @@ var DropListRef = /** @class */ (function () {
|
|
|
1186
1346
|
this._isDragging = false;
|
|
1187
1347
|
/** Cache of the dimensions of all the items inside the container. */
|
|
1188
1348
|
this._itemPositions = [];
|
|
1189
|
-
/** Cached positions of the scrollable parent elements. */
|
|
1190
|
-
this._parentPositions = new Map();
|
|
1191
1349
|
/**
|
|
1192
1350
|
* Keeps track of the item that was last swapped with the dragged item, as
|
|
1193
1351
|
* well as what direction the pointer was moving in when the swap occured.
|
|
@@ -1236,6 +1394,7 @@ var DropListRef = /** @class */ (function () {
|
|
|
1236
1394
|
this._document = _document;
|
|
1237
1395
|
this.withScrollableParents([this.element]);
|
|
1238
1396
|
_dragDropRegistry.registerDropContainer(this);
|
|
1397
|
+
this._parentPositions = new ParentPositionTracker(_document, _viewportRuler);
|
|
1239
1398
|
}
|
|
1240
1399
|
/** Removes the drop list functionality from the DOM element. */
|
|
1241
1400
|
DropListRef.prototype.dispose = function () {
|
|
@@ -1319,14 +1478,22 @@ var DropListRef = /** @class */ (function () {
|
|
|
1319
1478
|
activeDraggables.splice(newIndex, 0, item);
|
|
1320
1479
|
}
|
|
1321
1480
|
else {
|
|
1322
|
-
coerceElement(this.element)
|
|
1323
|
-
|
|
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
|
+
}
|
|
1324
1490
|
}
|
|
1325
1491
|
// The transform needs to be cleared so it doesn't throw off the measurements.
|
|
1326
1492
|
placeholder.style.transform = '';
|
|
1327
1493
|
// Note that the positions were already cached when we called `start` above,
|
|
1328
|
-
// 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.
|
|
1329
1495
|
this._cacheItemPositions();
|
|
1496
|
+
this._cacheParentPositions();
|
|
1330
1497
|
this.entered.next({ item: item, container: this, currentIndex: this.getItemIndex(item) });
|
|
1331
1498
|
};
|
|
1332
1499
|
/**
|
|
@@ -1370,10 +1537,19 @@ var DropListRef = /** @class */ (function () {
|
|
|
1370
1537
|
*/
|
|
1371
1538
|
DropListRef.prototype.withItems = function (items) {
|
|
1372
1539
|
var _this = this;
|
|
1540
|
+
var previousItems = this._draggables;
|
|
1373
1541
|
this._draggables = items;
|
|
1374
1542
|
items.forEach(function (item) { return item._withDropContainer(_this); });
|
|
1375
1543
|
if (this.isDragging()) {
|
|
1376
|
-
|
|
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
|
+
}
|
|
1377
1553
|
}
|
|
1378
1554
|
return this;
|
|
1379
1555
|
};
|
|
@@ -1411,6 +1587,10 @@ var DropListRef = /** @class */ (function () {
|
|
|
1411
1587
|
elements.indexOf(element) === -1 ? __spread([element], elements) : elements.slice();
|
|
1412
1588
|
return this;
|
|
1413
1589
|
};
|
|
1590
|
+
/** Gets the scrollable parents that are registered with this drop container. */
|
|
1591
|
+
DropListRef.prototype.getScrollableParents = function () {
|
|
1592
|
+
return this._scrollableElements;
|
|
1593
|
+
};
|
|
1414
1594
|
/**
|
|
1415
1595
|
* Figures out the index of an item in the container.
|
|
1416
1596
|
* @param item Item whose index should be determined.
|
|
@@ -1442,7 +1622,8 @@ var DropListRef = /** @class */ (function () {
|
|
|
1442
1622
|
*/
|
|
1443
1623
|
DropListRef.prototype._sortItem = function (item, pointerX, pointerY, pointerDelta) {
|
|
1444
1624
|
// Don't sort the item if sorting is disabled or it's out of range.
|
|
1445
|
-
if (this.sortingDisabled ||
|
|
1625
|
+
if (this.sortingDisabled ||
|
|
1626
|
+
!isPointerNearClientRect(this._clientRect, DROP_PROXIMITY_THRESHOLD, pointerX, pointerY)) {
|
|
1446
1627
|
return;
|
|
1447
1628
|
}
|
|
1448
1629
|
var siblings = this._itemPositions;
|
|
@@ -1515,14 +1696,14 @@ var DropListRef = /** @class */ (function () {
|
|
|
1515
1696
|
var verticalScrollDirection = 0 /* NONE */;
|
|
1516
1697
|
var horizontalScrollDirection = 0 /* NONE */;
|
|
1517
1698
|
// Check whether we should start scrolling any of the parent containers.
|
|
1518
|
-
this._parentPositions.forEach(function (position, element) {
|
|
1699
|
+
this._parentPositions.positions.forEach(function (position, element) {
|
|
1519
1700
|
var _a;
|
|
1520
1701
|
// We have special handling for the `document` below. Also this would be
|
|
1521
1702
|
// nicer with a for...of loop, but it requires changing a compiler flag.
|
|
1522
1703
|
if (element === _this._document || !position.clientRect || scrollNode) {
|
|
1523
1704
|
return;
|
|
1524
1705
|
}
|
|
1525
|
-
if (isPointerNearClientRect(position.clientRect, pointerX, pointerY)) {
|
|
1706
|
+
if (isPointerNearClientRect(position.clientRect, DROP_PROXIMITY_THRESHOLD, pointerX, pointerY)) {
|
|
1526
1707
|
_a = __read(getElementScrollDirections(element, position.clientRect, pointerX, pointerY), 2), verticalScrollDirection = _a[0], horizontalScrollDirection = _a[1];
|
|
1527
1708
|
if (verticalScrollDirection || horizontalScrollDirection) {
|
|
1528
1709
|
scrollNode = element;
|
|
@@ -1557,24 +1738,11 @@ var DropListRef = /** @class */ (function () {
|
|
|
1557
1738
|
};
|
|
1558
1739
|
/** Caches the positions of the configured scrollable parents. */
|
|
1559
1740
|
DropListRef.prototype._cacheParentPositions = function () {
|
|
1560
|
-
var
|
|
1561
|
-
this._parentPositions.
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
this._scrollableElements.forEach(function (element) {
|
|
1566
|
-
var clientRect = getMutableClientRect(element);
|
|
1567
|
-
// We keep the ClientRect cached in two properties, because it's referenced in a lot of
|
|
1568
|
-
// performance-sensitive places and we want to avoid the extra lookups. The `element` is
|
|
1569
|
-
// guaranteed to always be in the `_scrollableElements` so this should always match.
|
|
1570
|
-
if (element === _this.element) {
|
|
1571
|
-
_this._clientRect = clientRect;
|
|
1572
|
-
}
|
|
1573
|
-
_this._parentPositions.set(element, {
|
|
1574
|
-
scrollPosition: { top: element.scrollTop, left: element.scrollLeft },
|
|
1575
|
-
clientRect: clientRect
|
|
1576
|
-
});
|
|
1577
|
-
});
|
|
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;
|
|
1578
1746
|
};
|
|
1579
1747
|
/** Refreshes the position cache of the items and sibling containers. */
|
|
1580
1748
|
DropListRef.prototype._cacheItemPositions = function () {
|
|
@@ -1594,7 +1762,12 @@ var DropListRef = /** @class */ (function () {
|
|
|
1594
1762
|
var styles = coerceElement(this.element).style;
|
|
1595
1763
|
styles.scrollSnapType = styles.msScrollSnapType = this._initialScrollSnap;
|
|
1596
1764
|
// TODO(crisbeto): may have to wait for the animations to finish.
|
|
1597
|
-
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
|
+
});
|
|
1598
1771
|
this._siblings.forEach(function (sibling) { return sibling._stopReceiving(_this); });
|
|
1599
1772
|
this._activeDraggables = [];
|
|
1600
1773
|
this._itemPositions = [];
|
|
@@ -1648,6 +1821,29 @@ var DropListRef = /** @class */ (function () {
|
|
|
1648
1821
|
}
|
|
1649
1822
|
return itemOffset;
|
|
1650
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
|
+
};
|
|
1651
1847
|
/**
|
|
1652
1848
|
* Gets the index of an item in the drop container, based on the position of the user's pointer.
|
|
1653
1849
|
* @param item Item that is being sorted.
|
|
@@ -1676,8 +1872,8 @@ var DropListRef = /** @class */ (function () {
|
|
|
1676
1872
|
return isHorizontal ?
|
|
1677
1873
|
// Round these down since most browsers report client rects with
|
|
1678
1874
|
// sub-pixel precision, whereas the pointer coordinates are rounded to pixels.
|
|
1679
|
-
pointerX >= Math.floor(clientRect.left) && pointerX
|
|
1680
|
-
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);
|
|
1681
1877
|
});
|
|
1682
1878
|
};
|
|
1683
1879
|
/** Caches the current items in the list and their positions. */
|
|
@@ -1686,48 +1882,6 @@ var DropListRef = /** @class */ (function () {
|
|
|
1686
1882
|
this._cacheItemPositions();
|
|
1687
1883
|
this._cacheParentPositions();
|
|
1688
1884
|
};
|
|
1689
|
-
/**
|
|
1690
|
-
* Updates the internal state of the container after a scroll event has happened.
|
|
1691
|
-
* @param scrolledParent Element that was scrolled.
|
|
1692
|
-
* @param newTop New top scroll position.
|
|
1693
|
-
* @param newLeft New left scroll position.
|
|
1694
|
-
*/
|
|
1695
|
-
DropListRef.prototype._updateAfterScroll = function (scrolledParent, newTop, newLeft) {
|
|
1696
|
-
var _this = this;
|
|
1697
|
-
// Used when figuring out whether an element is inside the scroll parent. If the scrolled
|
|
1698
|
-
// parent is the `document`, we use the `documentElement`, because IE doesn't support `contains`
|
|
1699
|
-
// on the `document`.
|
|
1700
|
-
var scrolledParentNode = scrolledParent === this._document ? scrolledParent.documentElement : scrolledParent;
|
|
1701
|
-
var scrollPosition = this._parentPositions.get(scrolledParent).scrollPosition;
|
|
1702
|
-
var topDifference = scrollPosition.top - newTop;
|
|
1703
|
-
var leftDifference = scrollPosition.left - newLeft;
|
|
1704
|
-
// Go through and update the cached positions of the scroll
|
|
1705
|
-
// parents that are inside the element that was scrolled.
|
|
1706
|
-
this._parentPositions.forEach(function (position, node) {
|
|
1707
|
-
if (position.clientRect && scrolledParent !== node && scrolledParentNode.contains(node)) {
|
|
1708
|
-
adjustClientRect(position.clientRect, topDifference, leftDifference);
|
|
1709
|
-
}
|
|
1710
|
-
});
|
|
1711
|
-
// Since we know the amount that the user has scrolled we can shift all of the client rectangles
|
|
1712
|
-
// ourselves. This is cheaper than re-measuring everything and we can avoid inconsistent
|
|
1713
|
-
// behavior where we might be measuring the element before its position has changed.
|
|
1714
|
-
this._itemPositions.forEach(function (_a) {
|
|
1715
|
-
var clientRect = _a.clientRect;
|
|
1716
|
-
adjustClientRect(clientRect, topDifference, leftDifference);
|
|
1717
|
-
});
|
|
1718
|
-
// We need two loops for this, because we want all of the cached
|
|
1719
|
-
// positions to be up-to-date before we re-sort the item.
|
|
1720
|
-
this._itemPositions.forEach(function (_a) {
|
|
1721
|
-
var drag = _a.drag;
|
|
1722
|
-
if (_this._dragDropRegistry.isDragging(drag)) {
|
|
1723
|
-
// We need to re-sort the item manually, because the pointer move
|
|
1724
|
-
// events won't be dispatched while the user is scrolling.
|
|
1725
|
-
drag._sortFromLastPointerPosition();
|
|
1726
|
-
}
|
|
1727
|
-
});
|
|
1728
|
-
scrollPosition.top = newTop;
|
|
1729
|
-
scrollPosition.left = newLeft;
|
|
1730
|
-
};
|
|
1731
1885
|
/**
|
|
1732
1886
|
* Checks whether the user's pointer is positioned over the container.
|
|
1733
1887
|
* @param x Pointer position along the X axis.
|
|
@@ -1799,21 +1953,26 @@ var DropListRef = /** @class */ (function () {
|
|
|
1799
1953
|
var _this = this;
|
|
1800
1954
|
this._viewportScrollSubscription = this._dragDropRegistry.scroll.subscribe(function (event) {
|
|
1801
1955
|
if (_this.isDragging()) {
|
|
1802
|
-
var
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
}
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
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
|
+
});
|
|
1817
1976
|
}
|
|
1818
1977
|
}
|
|
1819
1978
|
else if (_this.isReceiving()) {
|
|
@@ -1836,31 +1995,6 @@ var DropListRef = /** @class */ (function () {
|
|
|
1836
1995
|
};
|
|
1837
1996
|
return DropListRef;
|
|
1838
1997
|
}());
|
|
1839
|
-
/**
|
|
1840
|
-
* Updates the top/left positions of a `ClientRect`, as well as their bottom/right counterparts.
|
|
1841
|
-
* @param clientRect `ClientRect` that should be updated.
|
|
1842
|
-
* @param top Amount to add to the `top` position.
|
|
1843
|
-
* @param left Amount to add to the `left` position.
|
|
1844
|
-
*/
|
|
1845
|
-
function adjustClientRect(clientRect, top, left) {
|
|
1846
|
-
clientRect.top += top;
|
|
1847
|
-
clientRect.bottom = clientRect.top + clientRect.height;
|
|
1848
|
-
clientRect.left += left;
|
|
1849
|
-
clientRect.right = clientRect.left + clientRect.width;
|
|
1850
|
-
}
|
|
1851
|
-
/**
|
|
1852
|
-
* Checks whether the pointer coordinates are close to a ClientRect.
|
|
1853
|
-
* @param rect ClientRect to check against.
|
|
1854
|
-
* @param pointerX Coordinates along the X axis.
|
|
1855
|
-
* @param pointerY Coordinates along the Y axis.
|
|
1856
|
-
*/
|
|
1857
|
-
function isPointerNearClientRect(rect, pointerX, pointerY) {
|
|
1858
|
-
var top = rect.top, right = rect.right, bottom = rect.bottom, left = rect.left, width = rect.width, height = rect.height;
|
|
1859
|
-
var xThreshold = width * DROP_PROXIMITY_THRESHOLD;
|
|
1860
|
-
var yThreshold = height * DROP_PROXIMITY_THRESHOLD;
|
|
1861
|
-
return pointerY > top - yThreshold && pointerY < bottom + yThreshold &&
|
|
1862
|
-
pointerX > left - xThreshold && pointerX < right + xThreshold;
|
|
1863
|
-
}
|
|
1864
1998
|
/**
|
|
1865
1999
|
* Finds the index of an item that matches a predicate function. Used as an equivalent
|
|
1866
2000
|
* of `Array.prototype.findIndex` which isn't part of the standard Google typings.
|
|
@@ -1875,32 +2009,6 @@ function findIndex(array, predicate) {
|
|
|
1875
2009
|
}
|
|
1876
2010
|
return -1;
|
|
1877
2011
|
}
|
|
1878
|
-
/**
|
|
1879
|
-
* Checks whether some coordinates are within a `ClientRect`.
|
|
1880
|
-
* @param clientRect ClientRect that is being checked.
|
|
1881
|
-
* @param x Coordinates along the X axis.
|
|
1882
|
-
* @param y Coordinates along the Y axis.
|
|
1883
|
-
*/
|
|
1884
|
-
function isInsideClientRect(clientRect, x, y) {
|
|
1885
|
-
var top = clientRect.top, bottom = clientRect.bottom, left = clientRect.left, right = clientRect.right;
|
|
1886
|
-
return y >= top && y <= bottom && x >= left && x <= right;
|
|
1887
|
-
}
|
|
1888
|
-
/** Gets a mutable version of an element's bounding `ClientRect`. */
|
|
1889
|
-
function getMutableClientRect(element) {
|
|
1890
|
-
var clientRect = element.getBoundingClientRect();
|
|
1891
|
-
// We need to clone the `clientRect` here, because all the values on it are readonly
|
|
1892
|
-
// and we need to be able to update them. Also we can't use a spread here, because
|
|
1893
|
-
// the values on a `ClientRect` aren't own properties. See:
|
|
1894
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect#Notes
|
|
1895
|
-
return {
|
|
1896
|
-
top: clientRect.top,
|
|
1897
|
-
right: clientRect.right,
|
|
1898
|
-
bottom: clientRect.bottom,
|
|
1899
|
-
left: clientRect.left,
|
|
1900
|
-
width: clientRect.width,
|
|
1901
|
-
height: clientRect.height
|
|
1902
|
-
};
|
|
1903
|
-
}
|
|
1904
2012
|
/**
|
|
1905
2013
|
* Increments the vertical scroll position of a node.
|
|
1906
2014
|
* @param node Node whose scroll position should change.
|
|
@@ -2445,7 +2553,8 @@ var CdkDrag = /** @class */ (function () {
|
|
|
2445
2553
|
dragStartThreshold: config && config.dragStartThreshold != null ?
|
|
2446
2554
|
config.dragStartThreshold : 5,
|
|
2447
2555
|
pointerDirectionChangeThreshold: config && config.pointerDirectionChangeThreshold != null ?
|
|
2448
|
-
config.pointerDirectionChangeThreshold : 5
|
|
2556
|
+
config.pointerDirectionChangeThreshold : 5,
|
|
2557
|
+
zIndex: config === null || config === void 0 ? void 0 : config.zIndex
|
|
2449
2558
|
});
|
|
2450
2559
|
this._dragRef.data = this;
|
|
2451
2560
|
if (config) {
|
|
@@ -2877,15 +2986,6 @@ var CdkDropList = /** @class */ (function () {
|
|
|
2877
2986
|
enumerable: true,
|
|
2878
2987
|
configurable: true
|
|
2879
2988
|
});
|
|
2880
|
-
CdkDropList.prototype.ngAfterContentInit = function () {
|
|
2881
|
-
// @breaking-change 11.0.0 Remove null check for _scrollDispatcher once it's required.
|
|
2882
|
-
if (this._scrollDispatcher) {
|
|
2883
|
-
var scrollableParents = this._scrollDispatcher
|
|
2884
|
-
.getAncestorScrollContainers(this.element)
|
|
2885
|
-
.map(function (scrollable) { return scrollable.getElementRef().nativeElement; });
|
|
2886
|
-
this._dropListRef.withScrollableParents(scrollableParents);
|
|
2887
|
-
}
|
|
2888
|
-
};
|
|
2889
2989
|
/** Registers an items with the drop list. */
|
|
2890
2990
|
CdkDropList.prototype.addItem = function (item) {
|
|
2891
2991
|
this._unsortedItems.add(item);
|
|
@@ -2994,6 +3094,18 @@ var CdkDropList = /** @class */ (function () {
|
|
|
2994
3094
|
}
|
|
2995
3095
|
});
|
|
2996
3096
|
}
|
|
3097
|
+
// Note that we resolve the scrollable parents here so that we delay the resolution
|
|
3098
|
+
// as long as possible, ensuring that the element is in its final place in the DOM.
|
|
3099
|
+
// @breaking-change 11.0.0 Remove null check for _scrollDispatcher once it's required.
|
|
3100
|
+
if (!_this._scrollableParentsResolved && _this._scrollDispatcher) {
|
|
3101
|
+
var scrollableParents = _this._scrollDispatcher
|
|
3102
|
+
.getAncestorScrollContainers(_this.element)
|
|
3103
|
+
.map(function (scrollable) { return scrollable.getElementRef().nativeElement; });
|
|
3104
|
+
_this._dropListRef.withScrollableParents(scrollableParents);
|
|
3105
|
+
// Only do this once since it involves traversing the DOM and the parents
|
|
3106
|
+
// shouldn't be able to change without the drop list being destroyed.
|
|
3107
|
+
_this._scrollableParentsResolved = true;
|
|
3108
|
+
}
|
|
2997
3109
|
ref.disabled = _this.disabled;
|
|
2998
3110
|
ref.lockAxis = _this.lockAxis;
|
|
2999
3111
|
ref.sortingDisabled = coerceBooleanProperty(_this.sortingDisabled);
|
|
@@ -3131,6 +3243,7 @@ var DragDropModule = /** @class */ (function () {
|
|
|
3131
3243
|
CdkDragPlaceholder,
|
|
3132
3244
|
],
|
|
3133
3245
|
exports: [
|
|
3246
|
+
CdkScrollableModule,
|
|
3134
3247
|
CdkDropList,
|
|
3135
3248
|
CdkDropListGroup,
|
|
3136
3249
|
CdkDrag,
|