@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
|
@@ -78,6 +78,138 @@
|
|
|
78
78
|
return value.split(',').map(function (part) { return part.trim(); });
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
/**
|
|
82
|
+
* @license
|
|
83
|
+
* Copyright Google LLC All Rights Reserved.
|
|
84
|
+
*
|
|
85
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
86
|
+
* found in the LICENSE file at https://angular.io/license
|
|
87
|
+
*/
|
|
88
|
+
/** Gets a mutable version of an element's bounding `ClientRect`. */
|
|
89
|
+
function getMutableClientRect(element) {
|
|
90
|
+
var clientRect = element.getBoundingClientRect();
|
|
91
|
+
// We need to clone the `clientRect` here, because all the values on it are readonly
|
|
92
|
+
// and we need to be able to update them. Also we can't use a spread here, because
|
|
93
|
+
// the values on a `ClientRect` aren't own properties. See:
|
|
94
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect#Notes
|
|
95
|
+
return {
|
|
96
|
+
top: clientRect.top,
|
|
97
|
+
right: clientRect.right,
|
|
98
|
+
bottom: clientRect.bottom,
|
|
99
|
+
left: clientRect.left,
|
|
100
|
+
width: clientRect.width,
|
|
101
|
+
height: clientRect.height
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Checks whether some coordinates are within a `ClientRect`.
|
|
106
|
+
* @param clientRect ClientRect that is being checked.
|
|
107
|
+
* @param x Coordinates along the X axis.
|
|
108
|
+
* @param y Coordinates along the Y axis.
|
|
109
|
+
*/
|
|
110
|
+
function isInsideClientRect(clientRect, x, y) {
|
|
111
|
+
var top = clientRect.top, bottom = clientRect.bottom, left = clientRect.left, right = clientRect.right;
|
|
112
|
+
return y >= top && y <= bottom && x >= left && x <= right;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Updates the top/left positions of a `ClientRect`, as well as their bottom/right counterparts.
|
|
116
|
+
* @param clientRect `ClientRect` that should be updated.
|
|
117
|
+
* @param top Amount to add to the `top` position.
|
|
118
|
+
* @param left Amount to add to the `left` position.
|
|
119
|
+
*/
|
|
120
|
+
function adjustClientRect(clientRect, top, left) {
|
|
121
|
+
clientRect.top += top;
|
|
122
|
+
clientRect.bottom = clientRect.top + clientRect.height;
|
|
123
|
+
clientRect.left += left;
|
|
124
|
+
clientRect.right = clientRect.left + clientRect.width;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Checks whether the pointer coordinates are close to a ClientRect.
|
|
128
|
+
* @param rect ClientRect to check against.
|
|
129
|
+
* @param threshold Threshold around the ClientRect.
|
|
130
|
+
* @param pointerX Coordinates along the X axis.
|
|
131
|
+
* @param pointerY Coordinates along the Y axis.
|
|
132
|
+
*/
|
|
133
|
+
function isPointerNearClientRect(rect, threshold, pointerX, pointerY) {
|
|
134
|
+
var top = rect.top, right = rect.right, bottom = rect.bottom, left = rect.left, width = rect.width, height = rect.height;
|
|
135
|
+
var xThreshold = width * threshold;
|
|
136
|
+
var yThreshold = height * threshold;
|
|
137
|
+
return pointerY > top - yThreshold && pointerY < bottom + yThreshold &&
|
|
138
|
+
pointerX > left - xThreshold && pointerX < right + xThreshold;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* @license
|
|
143
|
+
* Copyright Google LLC All Rights Reserved.
|
|
144
|
+
*
|
|
145
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
146
|
+
* found in the LICENSE file at https://angular.io/license
|
|
147
|
+
*/
|
|
148
|
+
/** Keeps track of the scroll position and dimensions of the parents of an element. */
|
|
149
|
+
var ParentPositionTracker = /** @class */ (function () {
|
|
150
|
+
function ParentPositionTracker(_document, _viewportRuler) {
|
|
151
|
+
this._document = _document;
|
|
152
|
+
this._viewportRuler = _viewportRuler;
|
|
153
|
+
/** Cached positions of the scrollable parent elements. */
|
|
154
|
+
this.positions = new Map();
|
|
155
|
+
}
|
|
156
|
+
/** Clears the cached positions. */
|
|
157
|
+
ParentPositionTracker.prototype.clear = function () {
|
|
158
|
+
this.positions.clear();
|
|
159
|
+
};
|
|
160
|
+
/** Caches the positions. Should be called at the beginning of a drag sequence. */
|
|
161
|
+
ParentPositionTracker.prototype.cache = function (elements) {
|
|
162
|
+
var _this = this;
|
|
163
|
+
this.clear();
|
|
164
|
+
this.positions.set(this._document, {
|
|
165
|
+
scrollPosition: this._viewportRuler.getViewportScrollPosition(),
|
|
166
|
+
});
|
|
167
|
+
elements.forEach(function (element) {
|
|
168
|
+
_this.positions.set(element, {
|
|
169
|
+
scrollPosition: { top: element.scrollTop, left: element.scrollLeft },
|
|
170
|
+
clientRect: getMutableClientRect(element)
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
};
|
|
174
|
+
/** Handles scrolling while a drag is taking place. */
|
|
175
|
+
ParentPositionTracker.prototype.handleScroll = function (event) {
|
|
176
|
+
var target = event.target;
|
|
177
|
+
var cachedPosition = this.positions.get(target);
|
|
178
|
+
if (!cachedPosition) {
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
// Used when figuring out whether an element is inside the scroll parent. If the scrolled
|
|
182
|
+
// parent is the `document`, we use the `documentElement`, because IE doesn't support
|
|
183
|
+
// `contains` on the `document`.
|
|
184
|
+
var scrolledParentNode = target === this._document ? target.documentElement : target;
|
|
185
|
+
var scrollPosition = cachedPosition.scrollPosition;
|
|
186
|
+
var newTop;
|
|
187
|
+
var newLeft;
|
|
188
|
+
if (target === this._document) {
|
|
189
|
+
var viewportScrollPosition = this._viewportRuler.getViewportScrollPosition();
|
|
190
|
+
newTop = viewportScrollPosition.top;
|
|
191
|
+
newLeft = viewportScrollPosition.left;
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
newTop = target.scrollTop;
|
|
195
|
+
newLeft = target.scrollLeft;
|
|
196
|
+
}
|
|
197
|
+
var topDifference = scrollPosition.top - newTop;
|
|
198
|
+
var leftDifference = scrollPosition.left - newLeft;
|
|
199
|
+
// Go through and update the cached positions of the scroll
|
|
200
|
+
// parents that are inside the element that was scrolled.
|
|
201
|
+
this.positions.forEach(function (position, node) {
|
|
202
|
+
if (position.clientRect && target !== node && scrolledParentNode.contains(node)) {
|
|
203
|
+
adjustClientRect(position.clientRect, topDifference, leftDifference);
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
scrollPosition.top = newTop;
|
|
207
|
+
scrollPosition.left = newLeft;
|
|
208
|
+
return { top: topDifference, left: leftDifference };
|
|
209
|
+
};
|
|
210
|
+
return ParentPositionTracker;
|
|
211
|
+
}());
|
|
212
|
+
|
|
81
213
|
/**
|
|
82
214
|
* @license
|
|
83
215
|
* Copyright Google LLC All Rights Reserved.
|
|
@@ -183,8 +315,8 @@
|
|
|
183
315
|
// Prevent the default action as early as possible in order to block
|
|
184
316
|
// native actions like dragging the selected text or images with the mouse.
|
|
185
317
|
event.preventDefault();
|
|
318
|
+
var pointerPosition = _this._getPointerPositionOnPage(event);
|
|
186
319
|
if (!_this._hasStartedDragging) {
|
|
187
|
-
var pointerPosition = _this._getPointerPositionOnPage(event);
|
|
188
320
|
var distanceX = Math.abs(pointerPosition.x - _this._pickupPositionOnPage.x);
|
|
189
321
|
var distanceY = Math.abs(pointerPosition.y - _this._pickupPositionOnPage.y);
|
|
190
322
|
var isOverThreshold = distanceX + distanceY >= _this._config.dragStartThreshold;
|
|
@@ -216,7 +348,7 @@
|
|
|
216
348
|
_this._previewRect = (_this._preview || _this._rootElement).getBoundingClientRect();
|
|
217
349
|
}
|
|
218
350
|
}
|
|
219
|
-
var constrainedPointerPosition = _this._getConstrainedPointerPosition(
|
|
351
|
+
var constrainedPointerPosition = _this._getConstrainedPointerPosition(pointerPosition);
|
|
220
352
|
_this._hasMoved = true;
|
|
221
353
|
_this._updatePointerDirectionDelta(constrainedPointerPosition);
|
|
222
354
|
if (_this._dropContainer) {
|
|
@@ -255,6 +387,7 @@
|
|
|
255
387
|
_this._endDragSequence(event);
|
|
256
388
|
};
|
|
257
389
|
this.withRootElement(element);
|
|
390
|
+
this._parentPositions = new ParentPositionTracker(_document, _viewportRuler);
|
|
258
391
|
_dragDropRegistry.registerDragItem(this);
|
|
259
392
|
}
|
|
260
393
|
Object.defineProperty(DragRef.prototype, "disabled", {
|
|
@@ -319,13 +452,16 @@
|
|
|
319
452
|
* dragging on an element that you might not have access to.
|
|
320
453
|
*/
|
|
321
454
|
DragRef.prototype.withRootElement = function (rootElement) {
|
|
455
|
+
var _this = this;
|
|
322
456
|
var element = coercion.coerceElement(rootElement);
|
|
323
457
|
if (element !== this._rootElement) {
|
|
324
458
|
if (this._rootElement) {
|
|
325
459
|
this._removeRootElementListeners(this._rootElement);
|
|
326
460
|
}
|
|
327
|
-
|
|
328
|
-
|
|
461
|
+
this._ngZone.runOutsideAngular(function () {
|
|
462
|
+
element.addEventListener('mousedown', _this._pointerDown, activeEventListenerOptions);
|
|
463
|
+
element.addEventListener('touchstart', _this._pointerDown, passiveEventListenerOptions);
|
|
464
|
+
});
|
|
329
465
|
this._initialTransform = undefined;
|
|
330
466
|
this._rootElement = element;
|
|
331
467
|
}
|
|
@@ -372,6 +508,7 @@
|
|
|
372
508
|
this._disabledHandles.clear();
|
|
373
509
|
this._dropContainer = undefined;
|
|
374
510
|
this._resizeSubscription.unsubscribe();
|
|
511
|
+
this._parentPositions.clear();
|
|
375
512
|
this._boundaryElement = this._rootElement = this._placeholderTemplate =
|
|
376
513
|
this._previewTemplate = this._anchor = null;
|
|
377
514
|
};
|
|
@@ -434,7 +571,7 @@
|
|
|
434
571
|
DragRef.prototype._sortFromLastPointerPosition = function () {
|
|
435
572
|
var position = this._pointerPositionAtLastDirectionChange;
|
|
436
573
|
if (position && this._dropContainer) {
|
|
437
|
-
this._updateActiveDropContainer(position);
|
|
574
|
+
this._updateActiveDropContainer(this._getConstrainedPointerPosition(position));
|
|
438
575
|
}
|
|
439
576
|
};
|
|
440
577
|
/** Unsubscribes from the global subscriptions. */
|
|
@@ -519,7 +656,8 @@
|
|
|
519
656
|
this._lastTouchEventTime = Date.now();
|
|
520
657
|
}
|
|
521
658
|
this._toggleNativeDragInteractions();
|
|
522
|
-
|
|
659
|
+
var dropContainer = this._dropContainer;
|
|
660
|
+
if (dropContainer) {
|
|
523
661
|
var element = this._rootElement;
|
|
524
662
|
var parent_1 = element.parentNode;
|
|
525
663
|
var preview = this._preview = this._createPreviewElement();
|
|
@@ -533,13 +671,16 @@
|
|
|
533
671
|
element.style.display = 'none';
|
|
534
672
|
this._document.body.appendChild(parent_1.replaceChild(placeholder, element));
|
|
535
673
|
getPreviewInsertionPoint(this._document).appendChild(preview);
|
|
536
|
-
|
|
537
|
-
this._initialContainer =
|
|
538
|
-
this._initialIndex =
|
|
674
|
+
dropContainer.start();
|
|
675
|
+
this._initialContainer = dropContainer;
|
|
676
|
+
this._initialIndex = dropContainer.getItemIndex(this);
|
|
539
677
|
}
|
|
540
678
|
else {
|
|
541
679
|
this._initialContainer = this._initialIndex = undefined;
|
|
542
680
|
}
|
|
681
|
+
// Important to run after we've called `start` on the parent container
|
|
682
|
+
// so that it has had time to resolve its scrollable parents.
|
|
683
|
+
this._parentPositions.cache(dropContainer ? dropContainer.getScrollableParents() : []);
|
|
543
684
|
};
|
|
544
685
|
/**
|
|
545
686
|
* Sets up the different variables and subscriptions
|
|
@@ -585,11 +726,11 @@
|
|
|
585
726
|
this._removeSubscriptions();
|
|
586
727
|
this._pointerMoveSubscription = this._dragDropRegistry.pointerMove.subscribe(this._pointerMove);
|
|
587
728
|
this._pointerUpSubscription = this._dragDropRegistry.pointerUp.subscribe(this._pointerUp);
|
|
588
|
-
this._scrollSubscription = this._dragDropRegistry.scroll.
|
|
589
|
-
_this.
|
|
729
|
+
this._scrollSubscription = this._dragDropRegistry.scroll.subscribe(function (scrollEvent) {
|
|
730
|
+
_this._updateOnScroll(scrollEvent);
|
|
590
731
|
});
|
|
591
732
|
if (this._boundaryElement) {
|
|
592
|
-
this._boundaryRect = this._boundaryElement
|
|
733
|
+
this._boundaryRect = getMutableClientRect(this._boundaryElement);
|
|
593
734
|
}
|
|
594
735
|
// If we have a custom preview we can't know ahead of time how large it'll be so we position
|
|
595
736
|
// it next to the cursor. The exception is when the consumer has opted into making the preview
|
|
@@ -686,13 +827,16 @@
|
|
|
686
827
|
var previewClass = this.previewClass;
|
|
687
828
|
var previewTemplate = previewConfig ? previewConfig.template : null;
|
|
688
829
|
var preview;
|
|
689
|
-
if (previewTemplate) {
|
|
830
|
+
if (previewTemplate && previewConfig) {
|
|
831
|
+
// Measure the element before we've inserted the preview
|
|
832
|
+
// since the insertion could throw off the measurement.
|
|
833
|
+
var rootRect = previewConfig.matchSize ? this._rootElement.getBoundingClientRect() : null;
|
|
690
834
|
var viewRef = previewConfig.viewContainer.createEmbeddedView(previewTemplate, previewConfig.context);
|
|
691
835
|
viewRef.detectChanges();
|
|
692
836
|
preview = getRootNode(viewRef, this._document);
|
|
693
837
|
this._previewRef = viewRef;
|
|
694
838
|
if (previewConfig.matchSize) {
|
|
695
|
-
matchElementSize(preview,
|
|
839
|
+
matchElementSize(preview, rootRect);
|
|
696
840
|
}
|
|
697
841
|
else {
|
|
698
842
|
preview.style.transform =
|
|
@@ -702,7 +846,7 @@
|
|
|
702
846
|
else {
|
|
703
847
|
var element = this._rootElement;
|
|
704
848
|
preview = deepCloneNode(element);
|
|
705
|
-
matchElementSize(preview, element);
|
|
849
|
+
matchElementSize(preview, element.getBoundingClientRect());
|
|
706
850
|
}
|
|
707
851
|
extendStyles(preview.style, {
|
|
708
852
|
// It's important that we disable the pointer events on the preview, because
|
|
@@ -713,7 +857,7 @@
|
|
|
713
857
|
position: 'fixed',
|
|
714
858
|
top: '0',
|
|
715
859
|
left: '0',
|
|
716
|
-
zIndex:
|
|
860
|
+
zIndex: "" + (this._config.zIndex || 1000)
|
|
717
861
|
});
|
|
718
862
|
toggleNativeDragInteractions(preview, false);
|
|
719
863
|
preview.classList.add('cdk-drag-preview');
|
|
@@ -794,8 +938,9 @@
|
|
|
794
938
|
var handleElement = referenceElement === this._rootElement ? null : referenceElement;
|
|
795
939
|
var referenceRect = handleElement ? handleElement.getBoundingClientRect() : elementRect;
|
|
796
940
|
var point = isTouchEvent(event) ? event.targetTouches[0] : event;
|
|
797
|
-
var
|
|
798
|
-
var
|
|
941
|
+
var scrollPosition = this._getViewportScrollPosition();
|
|
942
|
+
var x = point.pageX - referenceRect.left - scrollPosition.left;
|
|
943
|
+
var y = point.pageY - referenceRect.top - scrollPosition.top;
|
|
799
944
|
return {
|
|
800
945
|
x: referenceRect.left - elementRect.left + x,
|
|
801
946
|
y: referenceRect.top - elementRect.top + y
|
|
@@ -805,14 +950,14 @@
|
|
|
805
950
|
DragRef.prototype._getPointerPositionOnPage = function (event) {
|
|
806
951
|
// `touches` will be empty for start/end events so we have to fall back to `changedTouches`.
|
|
807
952
|
var point = isTouchEvent(event) ? (event.touches[0] || event.changedTouches[0]) : event;
|
|
953
|
+
var scrollPosition = this._getViewportScrollPosition();
|
|
808
954
|
return {
|
|
809
|
-
x: point.pageX -
|
|
810
|
-
y: point.pageY -
|
|
955
|
+
x: point.pageX - scrollPosition.left,
|
|
956
|
+
y: point.pageY - scrollPosition.top
|
|
811
957
|
};
|
|
812
958
|
};
|
|
813
959
|
/** Gets the pointer position on the page, accounting for any position constraints. */
|
|
814
|
-
DragRef.prototype._getConstrainedPointerPosition = function (
|
|
815
|
-
var point = this._getPointerPositionOnPage(event);
|
|
960
|
+
DragRef.prototype._getConstrainedPointerPosition = function (point) {
|
|
816
961
|
var constrainedPoint = this.constrainPosition ? this.constrainPosition(point, this) : point;
|
|
817
962
|
var dropContainerLock = this._dropContainer ? this._dropContainer.lockAxis : null;
|
|
818
963
|
if (this.lockAxis === 'x' || dropContainerLock === 'x') {
|
|
@@ -904,6 +1049,7 @@
|
|
|
904
1049
|
/** Cleans up any cached element dimensions that we don't need after dragging has stopped. */
|
|
905
1050
|
DragRef.prototype._cleanupCachedDimensions = function () {
|
|
906
1051
|
this._boundaryRect = this._previewRect = undefined;
|
|
1052
|
+
this._parentPositions.clear();
|
|
907
1053
|
};
|
|
908
1054
|
/**
|
|
909
1055
|
* Checks whether the element is still inside its boundary after the viewport has been resized.
|
|
@@ -967,6 +1113,21 @@
|
|
|
967
1113
|
}
|
|
968
1114
|
return value ? value.mouse : 0;
|
|
969
1115
|
};
|
|
1116
|
+
/** Updates the internal state of the draggable element when scrolling has occurred. */
|
|
1117
|
+
DragRef.prototype._updateOnScroll = function (event) {
|
|
1118
|
+
var scrollDifference = this._parentPositions.handleScroll(event);
|
|
1119
|
+
// ClientRect dimensions are based on the page's scroll position so
|
|
1120
|
+
// we have to update the cached boundary ClientRect if the user has scrolled.
|
|
1121
|
+
if (this._boundaryRect && scrollDifference) {
|
|
1122
|
+
adjustClientRect(this._boundaryRect, scrollDifference.top, scrollDifference.left);
|
|
1123
|
+
}
|
|
1124
|
+
};
|
|
1125
|
+
/** Gets the scroll position of the viewport. */
|
|
1126
|
+
DragRef.prototype._getViewportScrollPosition = function () {
|
|
1127
|
+
var cachedPosition = this._parentPositions.positions.get(this._document);
|
|
1128
|
+
return cachedPosition ? cachedPosition.scrollPosition :
|
|
1129
|
+
this._viewportRuler.getViewportScrollPosition();
|
|
1130
|
+
};
|
|
970
1131
|
return DragRef;
|
|
971
1132
|
}());
|
|
972
1133
|
/**
|
|
@@ -1038,21 +1199,20 @@
|
|
|
1038
1199
|
* If the root is not an HTML element it gets wrapped in one.
|
|
1039
1200
|
*/
|
|
1040
1201
|
function getRootNode(viewRef, _document) {
|
|
1041
|
-
var
|
|
1042
|
-
if (
|
|
1043
|
-
|
|
1044
|
-
wrapper.appendChild(rootNode);
|
|
1045
|
-
return wrapper;
|
|
1202
|
+
var rootNodes = viewRef.rootNodes;
|
|
1203
|
+
if (rootNodes.length === 1 && rootNodes[0].nodeType === _document.ELEMENT_NODE) {
|
|
1204
|
+
return rootNodes[0];
|
|
1046
1205
|
}
|
|
1047
|
-
|
|
1206
|
+
var wrapper = _document.createElement('div');
|
|
1207
|
+
rootNodes.forEach(function (node) { return wrapper.appendChild(node); });
|
|
1208
|
+
return wrapper;
|
|
1048
1209
|
}
|
|
1049
1210
|
/**
|
|
1050
1211
|
* Matches the target element's size to the source's size.
|
|
1051
1212
|
* @param target Element that needs to be resized.
|
|
1052
|
-
* @param
|
|
1213
|
+
* @param sourceRect Dimensions of the source element.
|
|
1053
1214
|
*/
|
|
1054
|
-
function matchElementSize(target,
|
|
1055
|
-
var sourceRect = source.getBoundingClientRect();
|
|
1215
|
+
function matchElementSize(target, sourceRect) {
|
|
1056
1216
|
target.style.width = sourceRect.width + "px";
|
|
1057
1217
|
target.style.height = sourceRect.height + "px";
|
|
1058
1218
|
target.style.transform = getTransform(sourceRect.left, sourceRect.top);
|
|
@@ -1379,8 +1539,6 @@
|
|
|
1379
1539
|
this._isDragging = false;
|
|
1380
1540
|
/** Cache of the dimensions of all the items inside the container. */
|
|
1381
1541
|
this._itemPositions = [];
|
|
1382
|
-
/** Cached positions of the scrollable parent elements. */
|
|
1383
|
-
this._parentPositions = new Map();
|
|
1384
1542
|
/**
|
|
1385
1543
|
* Keeps track of the item that was last swapped with the dragged item, as
|
|
1386
1544
|
* well as what direction the pointer was moving in when the swap occured.
|
|
@@ -1429,6 +1587,7 @@
|
|
|
1429
1587
|
this._document = _document;
|
|
1430
1588
|
this.withScrollableParents([this.element]);
|
|
1431
1589
|
_dragDropRegistry.registerDropContainer(this);
|
|
1590
|
+
this._parentPositions = new ParentPositionTracker(_document, _viewportRuler);
|
|
1432
1591
|
}
|
|
1433
1592
|
/** Removes the drop list functionality from the DOM element. */
|
|
1434
1593
|
DropListRef.prototype.dispose = function () {
|
|
@@ -1512,14 +1671,22 @@
|
|
|
1512
1671
|
activeDraggables.splice(newIndex, 0, item);
|
|
1513
1672
|
}
|
|
1514
1673
|
else {
|
|
1515
|
-
coercion.coerceElement(this.element)
|
|
1516
|
-
|
|
1674
|
+
var element = coercion.coerceElement(this.element);
|
|
1675
|
+
if (this._shouldEnterAsFirstChild(pointerX, pointerY)) {
|
|
1676
|
+
element.insertBefore(placeholder, activeDraggables[0].getRootElement());
|
|
1677
|
+
activeDraggables.unshift(item);
|
|
1678
|
+
}
|
|
1679
|
+
else {
|
|
1680
|
+
element.appendChild(placeholder);
|
|
1681
|
+
activeDraggables.push(item);
|
|
1682
|
+
}
|
|
1517
1683
|
}
|
|
1518
1684
|
// The transform needs to be cleared so it doesn't throw off the measurements.
|
|
1519
1685
|
placeholder.style.transform = '';
|
|
1520
1686
|
// Note that the positions were already cached when we called `start` above,
|
|
1521
|
-
// but we need to refresh them since the amount of items has changed.
|
|
1687
|
+
// but we need to refresh them since the amount of items has changed and also parent rects.
|
|
1522
1688
|
this._cacheItemPositions();
|
|
1689
|
+
this._cacheParentPositions();
|
|
1523
1690
|
this.entered.next({ item: item, container: this, currentIndex: this.getItemIndex(item) });
|
|
1524
1691
|
};
|
|
1525
1692
|
/**
|
|
@@ -1563,10 +1730,19 @@
|
|
|
1563
1730
|
*/
|
|
1564
1731
|
DropListRef.prototype.withItems = function (items) {
|
|
1565
1732
|
var _this = this;
|
|
1733
|
+
var previousItems = this._draggables;
|
|
1566
1734
|
this._draggables = items;
|
|
1567
1735
|
items.forEach(function (item) { return item._withDropContainer(_this); });
|
|
1568
1736
|
if (this.isDragging()) {
|
|
1569
|
-
|
|
1737
|
+
var draggedItems = previousItems.filter(function (item) { return item.isDragging(); });
|
|
1738
|
+
// If all of the items being dragged were removed
|
|
1739
|
+
// from the list, abort the current drag sequence.
|
|
1740
|
+
if (draggedItems.every(function (item) { return items.indexOf(item) === -1; })) {
|
|
1741
|
+
this._reset();
|
|
1742
|
+
}
|
|
1743
|
+
else {
|
|
1744
|
+
this._cacheItems();
|
|
1745
|
+
}
|
|
1570
1746
|
}
|
|
1571
1747
|
return this;
|
|
1572
1748
|
};
|
|
@@ -1604,6 +1780,10 @@
|
|
|
1604
1780
|
elements.indexOf(element) === -1 ? __spread([element], elements) : elements.slice();
|
|
1605
1781
|
return this;
|
|
1606
1782
|
};
|
|
1783
|
+
/** Gets the scrollable parents that are registered with this drop container. */
|
|
1784
|
+
DropListRef.prototype.getScrollableParents = function () {
|
|
1785
|
+
return this._scrollableElements;
|
|
1786
|
+
};
|
|
1607
1787
|
/**
|
|
1608
1788
|
* Figures out the index of an item in the container.
|
|
1609
1789
|
* @param item Item whose index should be determined.
|
|
@@ -1635,7 +1815,8 @@
|
|
|
1635
1815
|
*/
|
|
1636
1816
|
DropListRef.prototype._sortItem = function (item, pointerX, pointerY, pointerDelta) {
|
|
1637
1817
|
// Don't sort the item if sorting is disabled or it's out of range.
|
|
1638
|
-
if (this.sortingDisabled ||
|
|
1818
|
+
if (this.sortingDisabled ||
|
|
1819
|
+
!isPointerNearClientRect(this._clientRect, DROP_PROXIMITY_THRESHOLD, pointerX, pointerY)) {
|
|
1639
1820
|
return;
|
|
1640
1821
|
}
|
|
1641
1822
|
var siblings = this._itemPositions;
|
|
@@ -1708,14 +1889,14 @@
|
|
|
1708
1889
|
var verticalScrollDirection = 0 /* NONE */;
|
|
1709
1890
|
var horizontalScrollDirection = 0 /* NONE */;
|
|
1710
1891
|
// Check whether we should start scrolling any of the parent containers.
|
|
1711
|
-
this._parentPositions.forEach(function (position, element) {
|
|
1892
|
+
this._parentPositions.positions.forEach(function (position, element) {
|
|
1712
1893
|
var _a;
|
|
1713
1894
|
// We have special handling for the `document` below. Also this would be
|
|
1714
1895
|
// nicer with a for...of loop, but it requires changing a compiler flag.
|
|
1715
1896
|
if (element === _this._document || !position.clientRect || scrollNode) {
|
|
1716
1897
|
return;
|
|
1717
1898
|
}
|
|
1718
|
-
if (isPointerNearClientRect(position.clientRect, pointerX, pointerY)) {
|
|
1899
|
+
if (isPointerNearClientRect(position.clientRect, DROP_PROXIMITY_THRESHOLD, pointerX, pointerY)) {
|
|
1719
1900
|
_a = __read(getElementScrollDirections(element, position.clientRect, pointerX, pointerY), 2), verticalScrollDirection = _a[0], horizontalScrollDirection = _a[1];
|
|
1720
1901
|
if (verticalScrollDirection || horizontalScrollDirection) {
|
|
1721
1902
|
scrollNode = element;
|
|
@@ -1750,24 +1931,11 @@
|
|
|
1750
1931
|
};
|
|
1751
1932
|
/** Caches the positions of the configured scrollable parents. */
|
|
1752
1933
|
DropListRef.prototype._cacheParentPositions = function () {
|
|
1753
|
-
var
|
|
1754
|
-
this._parentPositions.
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
this._scrollableElements.forEach(function (element) {
|
|
1759
|
-
var clientRect = getMutableClientRect(element);
|
|
1760
|
-
// We keep the ClientRect cached in two properties, because it's referenced in a lot of
|
|
1761
|
-
// performance-sensitive places and we want to avoid the extra lookups. The `element` is
|
|
1762
|
-
// guaranteed to always be in the `_scrollableElements` so this should always match.
|
|
1763
|
-
if (element === _this.element) {
|
|
1764
|
-
_this._clientRect = clientRect;
|
|
1765
|
-
}
|
|
1766
|
-
_this._parentPositions.set(element, {
|
|
1767
|
-
scrollPosition: { top: element.scrollTop, left: element.scrollLeft },
|
|
1768
|
-
clientRect: clientRect
|
|
1769
|
-
});
|
|
1770
|
-
});
|
|
1934
|
+
var element = coercion.coerceElement(this.element);
|
|
1935
|
+
this._parentPositions.cache(this._scrollableElements);
|
|
1936
|
+
// The list element is always in the `scrollableElements`
|
|
1937
|
+
// so we can take advantage of the cached `ClientRect`.
|
|
1938
|
+
this._clientRect = this._parentPositions.positions.get(element).clientRect;
|
|
1771
1939
|
};
|
|
1772
1940
|
/** Refreshes the position cache of the items and sibling containers. */
|
|
1773
1941
|
DropListRef.prototype._cacheItemPositions = function () {
|
|
@@ -1787,7 +1955,12 @@
|
|
|
1787
1955
|
var styles = coercion.coerceElement(this.element).style;
|
|
1788
1956
|
styles.scrollSnapType = styles.msScrollSnapType = this._initialScrollSnap;
|
|
1789
1957
|
// TODO(crisbeto): may have to wait for the animations to finish.
|
|
1790
|
-
this._activeDraggables.forEach(function (item) {
|
|
1958
|
+
this._activeDraggables.forEach(function (item) {
|
|
1959
|
+
var rootElement = item.getRootElement();
|
|
1960
|
+
if (rootElement) {
|
|
1961
|
+
rootElement.style.transform = '';
|
|
1962
|
+
}
|
|
1963
|
+
});
|
|
1791
1964
|
this._siblings.forEach(function (sibling) { return sibling._stopReceiving(_this); });
|
|
1792
1965
|
this._activeDraggables = [];
|
|
1793
1966
|
this._itemPositions = [];
|
|
@@ -1841,6 +2014,29 @@
|
|
|
1841
2014
|
}
|
|
1842
2015
|
return itemOffset;
|
|
1843
2016
|
};
|
|
2017
|
+
/**
|
|
2018
|
+
* Checks if pointer is entering in the first position
|
|
2019
|
+
* @param pointerX Position of the user's pointer along the X axis.
|
|
2020
|
+
* @param pointerY Position of the user's pointer along the Y axis.
|
|
2021
|
+
*/
|
|
2022
|
+
DropListRef.prototype._shouldEnterAsFirstChild = function (pointerX, pointerY) {
|
|
2023
|
+
if (!this._activeDraggables.length) {
|
|
2024
|
+
return false;
|
|
2025
|
+
}
|
|
2026
|
+
var itemPositions = this._itemPositions;
|
|
2027
|
+
var isHorizontal = this._orientation === 'horizontal';
|
|
2028
|
+
// `itemPositions` are sorted by position while `activeDraggables` are sorted by child index
|
|
2029
|
+
// check if container is using some sort of "reverse" ordering (eg: flex-direction: row-reverse)
|
|
2030
|
+
var reversed = itemPositions[0].drag !== this._activeDraggables[0];
|
|
2031
|
+
if (reversed) {
|
|
2032
|
+
var lastItemRect = itemPositions[itemPositions.length - 1].clientRect;
|
|
2033
|
+
return isHorizontal ? pointerX >= lastItemRect.right : pointerY >= lastItemRect.bottom;
|
|
2034
|
+
}
|
|
2035
|
+
else {
|
|
2036
|
+
var firstItemRect = itemPositions[0].clientRect;
|
|
2037
|
+
return isHorizontal ? pointerX <= firstItemRect.left : pointerY <= firstItemRect.top;
|
|
2038
|
+
}
|
|
2039
|
+
};
|
|
1844
2040
|
/**
|
|
1845
2041
|
* Gets the index of an item in the drop container, based on the position of the user's pointer.
|
|
1846
2042
|
* @param item Item that is being sorted.
|
|
@@ -1869,8 +2065,8 @@
|
|
|
1869
2065
|
return isHorizontal ?
|
|
1870
2066
|
// Round these down since most browsers report client rects with
|
|
1871
2067
|
// sub-pixel precision, whereas the pointer coordinates are rounded to pixels.
|
|
1872
|
-
pointerX >= Math.floor(clientRect.left) && pointerX
|
|
1873
|
-
pointerY >= Math.floor(clientRect.top) && pointerY
|
|
2068
|
+
pointerX >= Math.floor(clientRect.left) && pointerX < Math.floor(clientRect.right) :
|
|
2069
|
+
pointerY >= Math.floor(clientRect.top) && pointerY < Math.floor(clientRect.bottom);
|
|
1874
2070
|
});
|
|
1875
2071
|
};
|
|
1876
2072
|
/** Caches the current items in the list and their positions. */
|
|
@@ -1879,48 +2075,6 @@
|
|
|
1879
2075
|
this._cacheItemPositions();
|
|
1880
2076
|
this._cacheParentPositions();
|
|
1881
2077
|
};
|
|
1882
|
-
/**
|
|
1883
|
-
* Updates the internal state of the container after a scroll event has happened.
|
|
1884
|
-
* @param scrolledParent Element that was scrolled.
|
|
1885
|
-
* @param newTop New top scroll position.
|
|
1886
|
-
* @param newLeft New left scroll position.
|
|
1887
|
-
*/
|
|
1888
|
-
DropListRef.prototype._updateAfterScroll = function (scrolledParent, newTop, newLeft) {
|
|
1889
|
-
var _this = this;
|
|
1890
|
-
// Used when figuring out whether an element is inside the scroll parent. If the scrolled
|
|
1891
|
-
// parent is the `document`, we use the `documentElement`, because IE doesn't support `contains`
|
|
1892
|
-
// on the `document`.
|
|
1893
|
-
var scrolledParentNode = scrolledParent === this._document ? scrolledParent.documentElement : scrolledParent;
|
|
1894
|
-
var scrollPosition = this._parentPositions.get(scrolledParent).scrollPosition;
|
|
1895
|
-
var topDifference = scrollPosition.top - newTop;
|
|
1896
|
-
var leftDifference = scrollPosition.left - newLeft;
|
|
1897
|
-
// Go through and update the cached positions of the scroll
|
|
1898
|
-
// parents that are inside the element that was scrolled.
|
|
1899
|
-
this._parentPositions.forEach(function (position, node) {
|
|
1900
|
-
if (position.clientRect && scrolledParent !== node && scrolledParentNode.contains(node)) {
|
|
1901
|
-
adjustClientRect(position.clientRect, topDifference, leftDifference);
|
|
1902
|
-
}
|
|
1903
|
-
});
|
|
1904
|
-
// Since we know the amount that the user has scrolled we can shift all of the client rectangles
|
|
1905
|
-
// ourselves. This is cheaper than re-measuring everything and we can avoid inconsistent
|
|
1906
|
-
// behavior where we might be measuring the element before its position has changed.
|
|
1907
|
-
this._itemPositions.forEach(function (_a) {
|
|
1908
|
-
var clientRect = _a.clientRect;
|
|
1909
|
-
adjustClientRect(clientRect, topDifference, leftDifference);
|
|
1910
|
-
});
|
|
1911
|
-
// We need two loops for this, because we want all of the cached
|
|
1912
|
-
// positions to be up-to-date before we re-sort the item.
|
|
1913
|
-
this._itemPositions.forEach(function (_a) {
|
|
1914
|
-
var drag = _a.drag;
|
|
1915
|
-
if (_this._dragDropRegistry.isDragging(drag)) {
|
|
1916
|
-
// We need to re-sort the item manually, because the pointer move
|
|
1917
|
-
// events won't be dispatched while the user is scrolling.
|
|
1918
|
-
drag._sortFromLastPointerPosition();
|
|
1919
|
-
}
|
|
1920
|
-
});
|
|
1921
|
-
scrollPosition.top = newTop;
|
|
1922
|
-
scrollPosition.left = newLeft;
|
|
1923
|
-
};
|
|
1924
2078
|
/**
|
|
1925
2079
|
* Checks whether the user's pointer is positioned over the container.
|
|
1926
2080
|
* @param x Pointer position along the X axis.
|
|
@@ -1992,21 +2146,26 @@
|
|
|
1992
2146
|
var _this = this;
|
|
1993
2147
|
this._viewportScrollSubscription = this._dragDropRegistry.scroll.subscribe(function (event) {
|
|
1994
2148
|
if (_this.isDragging()) {
|
|
1995
|
-
var
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
}
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2149
|
+
var scrollDifference_1 = _this._parentPositions.handleScroll(event);
|
|
2150
|
+
if (scrollDifference_1) {
|
|
2151
|
+
// Since we know the amount that the user has scrolled we can shift all of the
|
|
2152
|
+
// client rectangles ourselves. This is cheaper than re-measuring everything and
|
|
2153
|
+
// we can avoid inconsistent behavior where we might be measuring the element before
|
|
2154
|
+
// its position has changed.
|
|
2155
|
+
_this._itemPositions.forEach(function (_a) {
|
|
2156
|
+
var clientRect = _a.clientRect;
|
|
2157
|
+
adjustClientRect(clientRect, scrollDifference_1.top, scrollDifference_1.left);
|
|
2158
|
+
});
|
|
2159
|
+
// We need two loops for this, because we want all of the cached
|
|
2160
|
+
// positions to be up-to-date before we re-sort the item.
|
|
2161
|
+
_this._itemPositions.forEach(function (_a) {
|
|
2162
|
+
var drag = _a.drag;
|
|
2163
|
+
if (_this._dragDropRegistry.isDragging(drag)) {
|
|
2164
|
+
// We need to re-sort the item manually, because the pointer move
|
|
2165
|
+
// events won't be dispatched while the user is scrolling.
|
|
2166
|
+
drag._sortFromLastPointerPosition();
|
|
2167
|
+
}
|
|
2168
|
+
});
|
|
2010
2169
|
}
|
|
2011
2170
|
}
|
|
2012
2171
|
else if (_this.isReceiving()) {
|
|
@@ -2029,31 +2188,6 @@
|
|
|
2029
2188
|
};
|
|
2030
2189
|
return DropListRef;
|
|
2031
2190
|
}());
|
|
2032
|
-
/**
|
|
2033
|
-
* Updates the top/left positions of a `ClientRect`, as well as their bottom/right counterparts.
|
|
2034
|
-
* @param clientRect `ClientRect` that should be updated.
|
|
2035
|
-
* @param top Amount to add to the `top` position.
|
|
2036
|
-
* @param left Amount to add to the `left` position.
|
|
2037
|
-
*/
|
|
2038
|
-
function adjustClientRect(clientRect, top, left) {
|
|
2039
|
-
clientRect.top += top;
|
|
2040
|
-
clientRect.bottom = clientRect.top + clientRect.height;
|
|
2041
|
-
clientRect.left += left;
|
|
2042
|
-
clientRect.right = clientRect.left + clientRect.width;
|
|
2043
|
-
}
|
|
2044
|
-
/**
|
|
2045
|
-
* Checks whether the pointer coordinates are close to a ClientRect.
|
|
2046
|
-
* @param rect ClientRect to check against.
|
|
2047
|
-
* @param pointerX Coordinates along the X axis.
|
|
2048
|
-
* @param pointerY Coordinates along the Y axis.
|
|
2049
|
-
*/
|
|
2050
|
-
function isPointerNearClientRect(rect, pointerX, pointerY) {
|
|
2051
|
-
var top = rect.top, right = rect.right, bottom = rect.bottom, left = rect.left, width = rect.width, height = rect.height;
|
|
2052
|
-
var xThreshold = width * DROP_PROXIMITY_THRESHOLD;
|
|
2053
|
-
var yThreshold = height * DROP_PROXIMITY_THRESHOLD;
|
|
2054
|
-
return pointerY > top - yThreshold && pointerY < bottom + yThreshold &&
|
|
2055
|
-
pointerX > left - xThreshold && pointerX < right + xThreshold;
|
|
2056
|
-
}
|
|
2057
2191
|
/**
|
|
2058
2192
|
* Finds the index of an item that matches a predicate function. Used as an equivalent
|
|
2059
2193
|
* of `Array.prototype.findIndex` which isn't part of the standard Google typings.
|
|
@@ -2068,32 +2202,6 @@
|
|
|
2068
2202
|
}
|
|
2069
2203
|
return -1;
|
|
2070
2204
|
}
|
|
2071
|
-
/**
|
|
2072
|
-
* Checks whether some coordinates are within a `ClientRect`.
|
|
2073
|
-
* @param clientRect ClientRect that is being checked.
|
|
2074
|
-
* @param x Coordinates along the X axis.
|
|
2075
|
-
* @param y Coordinates along the Y axis.
|
|
2076
|
-
*/
|
|
2077
|
-
function isInsideClientRect(clientRect, x, y) {
|
|
2078
|
-
var top = clientRect.top, bottom = clientRect.bottom, left = clientRect.left, right = clientRect.right;
|
|
2079
|
-
return y >= top && y <= bottom && x >= left && x <= right;
|
|
2080
|
-
}
|
|
2081
|
-
/** Gets a mutable version of an element's bounding `ClientRect`. */
|
|
2082
|
-
function getMutableClientRect(element) {
|
|
2083
|
-
var clientRect = element.getBoundingClientRect();
|
|
2084
|
-
// We need to clone the `clientRect` here, because all the values on it are readonly
|
|
2085
|
-
// and we need to be able to update them. Also we can't use a spread here, because
|
|
2086
|
-
// the values on a `ClientRect` aren't own properties. See:
|
|
2087
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect#Notes
|
|
2088
|
-
return {
|
|
2089
|
-
top: clientRect.top,
|
|
2090
|
-
right: clientRect.right,
|
|
2091
|
-
bottom: clientRect.bottom,
|
|
2092
|
-
left: clientRect.left,
|
|
2093
|
-
width: clientRect.width,
|
|
2094
|
-
height: clientRect.height
|
|
2095
|
-
};
|
|
2096
|
-
}
|
|
2097
2205
|
/**
|
|
2098
2206
|
* Increments the vertical scroll position of a node.
|
|
2099
2207
|
* @param node Node whose scroll position should change.
|
|
@@ -2638,7 +2746,8 @@
|
|
|
2638
2746
|
dragStartThreshold: config && config.dragStartThreshold != null ?
|
|
2639
2747
|
config.dragStartThreshold : 5,
|
|
2640
2748
|
pointerDirectionChangeThreshold: config && config.pointerDirectionChangeThreshold != null ?
|
|
2641
|
-
config.pointerDirectionChangeThreshold : 5
|
|
2749
|
+
config.pointerDirectionChangeThreshold : 5,
|
|
2750
|
+
zIndex: config === null || config === void 0 ? void 0 : config.zIndex
|
|
2642
2751
|
});
|
|
2643
2752
|
this._dragRef.data = this;
|
|
2644
2753
|
if (config) {
|
|
@@ -3070,15 +3179,6 @@
|
|
|
3070
3179
|
enumerable: true,
|
|
3071
3180
|
configurable: true
|
|
3072
3181
|
});
|
|
3073
|
-
CdkDropList.prototype.ngAfterContentInit = function () {
|
|
3074
|
-
// @breaking-change 11.0.0 Remove null check for _scrollDispatcher once it's required.
|
|
3075
|
-
if (this._scrollDispatcher) {
|
|
3076
|
-
var scrollableParents = this._scrollDispatcher
|
|
3077
|
-
.getAncestorScrollContainers(this.element)
|
|
3078
|
-
.map(function (scrollable) { return scrollable.getElementRef().nativeElement; });
|
|
3079
|
-
this._dropListRef.withScrollableParents(scrollableParents);
|
|
3080
|
-
}
|
|
3081
|
-
};
|
|
3082
3182
|
/** Registers an items with the drop list. */
|
|
3083
3183
|
CdkDropList.prototype.addItem = function (item) {
|
|
3084
3184
|
this._unsortedItems.add(item);
|
|
@@ -3187,6 +3287,18 @@
|
|
|
3187
3287
|
}
|
|
3188
3288
|
});
|
|
3189
3289
|
}
|
|
3290
|
+
// Note that we resolve the scrollable parents here so that we delay the resolution
|
|
3291
|
+
// as long as possible, ensuring that the element is in its final place in the DOM.
|
|
3292
|
+
// @breaking-change 11.0.0 Remove null check for _scrollDispatcher once it's required.
|
|
3293
|
+
if (!_this._scrollableParentsResolved && _this._scrollDispatcher) {
|
|
3294
|
+
var scrollableParents = _this._scrollDispatcher
|
|
3295
|
+
.getAncestorScrollContainers(_this.element)
|
|
3296
|
+
.map(function (scrollable) { return scrollable.getElementRef().nativeElement; });
|
|
3297
|
+
_this._dropListRef.withScrollableParents(scrollableParents);
|
|
3298
|
+
// Only do this once since it involves traversing the DOM and the parents
|
|
3299
|
+
// shouldn't be able to change without the drop list being destroyed.
|
|
3300
|
+
_this._scrollableParentsResolved = true;
|
|
3301
|
+
}
|
|
3190
3302
|
ref.disabled = _this.disabled;
|
|
3191
3303
|
ref.lockAxis = _this.lockAxis;
|
|
3192
3304
|
ref.sortingDisabled = coercion.coerceBooleanProperty(_this.sortingDisabled);
|
|
@@ -3324,6 +3436,7 @@
|
|
|
3324
3436
|
CdkDragPlaceholder,
|
|
3325
3437
|
],
|
|
3326
3438
|
exports: [
|
|
3439
|
+
i2.CdkScrollableModule,
|
|
3327
3440
|
CdkDropList,
|
|
3328
3441
|
CdkDropListGroup,
|
|
3329
3442
|
CdkDrag,
|