@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.
Files changed (241) hide show
  1. package/a11y/focus-monitor/focus-monitor.d.ts +43 -4
  2. package/a11y/high-contrast-mode/high-contrast-mode-detector.d.ts +2 -2
  3. package/a11y/index.metadata.json +1 -1
  4. package/bundles/cdk-a11y.umd.js +140 -90
  5. package/bundles/cdk-a11y.umd.js.map +1 -1
  6. package/bundles/cdk-a11y.umd.min.js +14 -7
  7. package/bundles/cdk-a11y.umd.min.js.map +1 -1
  8. package/bundles/cdk-coercion.umd.js +0 -1
  9. package/bundles/cdk-coercion.umd.js.map +1 -1
  10. package/bundles/cdk-coercion.umd.min.js.map +1 -1
  11. package/bundles/cdk-drag-drop.umd.js +292 -179
  12. package/bundles/cdk-drag-drop.umd.js.map +1 -1
  13. package/bundles/cdk-drag-drop.umd.min.js +23 -9
  14. package/bundles/cdk-drag-drop.umd.min.js.map +1 -1
  15. package/bundles/cdk-overlay.umd.js.map +1 -1
  16. package/bundles/cdk-platform.umd.js +3 -1
  17. package/bundles/cdk-platform.umd.js.map +1 -1
  18. package/bundles/cdk-platform.umd.min.js +4 -4
  19. package/bundles/cdk-platform.umd.min.js.map +1 -1
  20. package/bundles/cdk-scrolling.umd.js +18 -3
  21. package/bundles/cdk-scrolling.umd.js.map +1 -1
  22. package/bundles/cdk-scrolling.umd.min.js +2 -2
  23. package/bundles/cdk-scrolling.umd.min.js.map +1 -1
  24. package/bundles/cdk-table.umd.js +58 -27
  25. package/bundles/cdk-table.umd.js.map +1 -1
  26. package/bundles/cdk-table.umd.min.js +12 -5
  27. package/bundles/cdk-table.umd.min.js.map +1 -1
  28. package/bundles/cdk-testing-protractor.umd.js +15 -9
  29. package/bundles/cdk-testing-protractor.umd.js.map +1 -1
  30. package/bundles/cdk-testing-protractor.umd.min.js +2 -2
  31. package/bundles/cdk-testing-protractor.umd.min.js.map +1 -1
  32. package/bundles/cdk-testing-testbed.umd.js +77 -19
  33. package/bundles/cdk-testing-testbed.umd.js.map +1 -1
  34. package/bundles/cdk-testing-testbed.umd.min.js +8 -8
  35. package/bundles/cdk-testing-testbed.umd.min.js.map +1 -1
  36. package/bundles/cdk-tree.umd.js +9 -4
  37. package/bundles/cdk-tree.umd.js.map +1 -1
  38. package/bundles/cdk-tree.umd.min.js +1 -1
  39. package/bundles/cdk-tree.umd.min.js.map +1 -1
  40. package/bundles/cdk.umd.js +1 -1
  41. package/bundles/cdk.umd.js.map +1 -1
  42. package/bundles/cdk.umd.min.js +1 -1
  43. package/bundles/cdk.umd.min.js.map +1 -1
  44. package/coercion/array.d.ts +1 -0
  45. package/drag-drop/client-rect.d.ts +31 -0
  46. package/drag-drop/directives/config.d.ts +1 -0
  47. package/drag-drop/directives/drop-list.d.ts +4 -3
  48. package/drag-drop/drag-ref.d.ts +8 -2
  49. package/drag-drop/drop-list-ref.d.ts +9 -8
  50. package/drag-drop/index.metadata.json +1 -1
  51. package/drag-drop/parent-position-tracker.d.ts +31 -0
  52. package/drag-drop/public-api.d.ts +1 -1
  53. package/esm2015/a11y/aria-describer/aria-reference.js +6 -6
  54. package/esm2015/a11y/focus-monitor/focus-monitor.js +198 -92
  55. package/esm2015/a11y/focus-trap/configurable-focus-trap-factory.js +3 -3
  56. package/esm2015/a11y/focus-trap/focus-trap.js +1 -1
  57. package/esm2015/a11y/high-contrast-mode/high-contrast-mode-detector.js +10 -6
  58. package/esm2015/a11y/live-announcer/live-announcer.js +1 -1
  59. package/esm2015/a11y/public-api.js +2 -2
  60. package/esm2015/coercion/array.js +1 -2
  61. package/esm2015/drag-drop/client-rect.js +75 -0
  62. package/esm2015/drag-drop/directives/config.js +3 -1
  63. package/esm2015/drag-drop/directives/drag.js +3 -2
  64. package/esm2015/drag-drop/directives/drop-list.js +24 -18
  65. package/esm2015/drag-drop/drag-drop-module.js +3 -1
  66. package/esm2015/drag-drop/drag-ref.js +97 -43
  67. package/esm2015/drag-drop/drop-list-ref.js +119 -187
  68. package/esm2015/drag-drop/parent-position-tracker.js +141 -0
  69. package/esm2015/drag-drop/public-api.js +1 -1
  70. package/esm2015/overlay/position/flexible-connected-position-strategy.js +1 -1
  71. package/esm2015/platform/features/shadow-dom.js +4 -2
  72. package/esm2015/scrolling/public-api.js +2 -2
  73. package/esm2015/scrolling/scrolling-module.js +15 -4
  74. package/esm2015/table/cell.js +18 -8
  75. package/esm2015/table/public-api.js +3 -2
  76. package/esm2015/table/row.js +24 -8
  77. package/esm2015/table/table.js +26 -12
  78. package/esm2015/table/text-column.js +3 -26
  79. package/esm2015/table/tokens.js +44 -0
  80. package/esm2015/testing/protractor/protractor-harness-environment.js +13 -8
  81. package/esm2015/testing/testbed/fake-events/dispatch-events.js +11 -4
  82. package/esm2015/testing/testbed/fake-events/event-objects.js +37 -3
  83. package/esm2015/testing/testbed/testbed-harness-environment.js +16 -10
  84. package/esm2015/testing/testbed/unit-test-element.js +13 -2
  85. package/esm2015/tree/padding.js +9 -10
  86. package/esm2015/tree/tree.js +2 -1
  87. package/esm2015/version.js +1 -1
  88. package/esm5/a11y/aria-describer/aria-reference.js +6 -6
  89. package/esm5/a11y/focus-monitor/focus-monitor.js +112 -65
  90. package/esm5/a11y/high-contrast-mode/high-contrast-mode-detector.js +9 -6
  91. package/esm5/coercion/array.js +1 -2
  92. package/esm5/drag-drop/client-rect.js +60 -0
  93. package/esm5/drag-drop/directives/config.js +1 -1
  94. package/esm5/drag-drop/directives/drag.js +3 -2
  95. package/esm5/drag-drop/directives/drop-list.js +13 -10
  96. package/esm5/drag-drop/drag-drop-module.js +3 -1
  97. package/esm5/drag-drop/drag-ref.js +62 -33
  98. package/esm5/drag-drop/drop-list-ref.js +89 -139
  99. package/esm5/drag-drop/parent-position-tracker.js +74 -0
  100. package/esm5/drag-drop/public-api.js +1 -1
  101. package/esm5/overlay/position/flexible-connected-position-strategy.js +1 -1
  102. package/esm5/platform/features/shadow-dom.js +4 -2
  103. package/esm5/scrolling/scrolling-module.js +19 -4
  104. package/esm5/table/cell.js +13 -8
  105. package/esm5/table/public-api.js +2 -1
  106. package/esm5/table/row.js +21 -11
  107. package/esm5/table/table.js +16 -11
  108. package/esm5/table/text-column.js +3 -4
  109. package/esm5/table/tokens.js +16 -0
  110. package/esm5/testing/protractor/protractor-harness-environment.js +17 -11
  111. package/esm5/testing/testbed/fake-events/dispatch-events.js +15 -7
  112. package/esm5/testing/testbed/fake-events/event-objects.js +43 -5
  113. package/esm5/testing/testbed/testbed-harness-environment.js +17 -11
  114. package/esm5/testing/testbed/unit-test-element.js +10 -3
  115. package/esm5/tree/padding.js +9 -5
  116. package/esm5/tree/tree.js +2 -1
  117. package/esm5/version.js +1 -1
  118. package/fesm2015/a11y.js +234 -126
  119. package/fesm2015/a11y.js.map +1 -1
  120. package/fesm2015/cdk.js +1 -1
  121. package/fesm2015/cdk.js.map +1 -1
  122. package/fesm2015/coercion.js +0 -1
  123. package/fesm2015/coercion.js.map +1 -1
  124. package/fesm2015/drag-drop.js +448 -247
  125. package/fesm2015/drag-drop.js.map +1 -1
  126. package/fesm2015/overlay.js.map +1 -1
  127. package/fesm2015/platform.js +3 -1
  128. package/fesm2015/platform.js.map +1 -1
  129. package/fesm2015/scrolling.js +15 -4
  130. package/fesm2015/scrolling.js.map +1 -1
  131. package/fesm2015/table.js +98 -49
  132. package/fesm2015/table.js.map +1 -1
  133. package/fesm2015/testing/protractor.js +13 -8
  134. package/fesm2015/testing/protractor.js.map +1 -1
  135. package/fesm2015/testing/testbed.js +71 -13
  136. package/fesm2015/testing/testbed.js.map +1 -1
  137. package/fesm2015/tree.js +9 -9
  138. package/fesm2015/tree.js.map +1 -1
  139. package/fesm5/a11y.js +141 -92
  140. package/fesm5/a11y.js.map +1 -1
  141. package/fesm5/cdk.js +1 -1
  142. package/fesm5/cdk.js.map +1 -1
  143. package/fesm5/coercion.js +0 -1
  144. package/fesm5/coercion.js.map +1 -1
  145. package/fesm5/drag-drop.js +294 -181
  146. package/fesm5/drag-drop.js.map +1 -1
  147. package/fesm5/overlay.js.map +1 -1
  148. package/fesm5/platform.js +3 -1
  149. package/fesm5/platform.js.map +1 -1
  150. package/fesm5/scrolling.js +18 -4
  151. package/fesm5/scrolling.js.map +1 -1
  152. package/fesm5/table.js +59 -29
  153. package/fesm5/table.js.map +1 -1
  154. package/fesm5/testing/protractor.js +17 -11
  155. package/fesm5/testing/protractor.js.map +1 -1
  156. package/fesm5/testing/testbed.js +78 -20
  157. package/fesm5/testing/testbed.js.map +1 -1
  158. package/fesm5/tree.js +9 -4
  159. package/fesm5/tree.js.map +1 -1
  160. package/overlay/position/flexible-connected-position-strategy.d.ts +1 -1
  161. package/package.json +1 -1
  162. package/schematics/ng-add/index.js +1 -1
  163. package/schematics/ng-update/devkit-file-system.d.ts +29 -0
  164. package/schematics/ng-update/devkit-file-system.js +67 -0
  165. package/schematics/ng-update/devkit-migration-rule.d.ts +25 -0
  166. package/schematics/ng-update/devkit-migration-rule.js +152 -0
  167. package/schematics/ng-update/devkit-migration.d.ts +37 -0
  168. package/schematics/ng-update/devkit-migration.js +29 -0
  169. package/schematics/ng-update/index.js +7 -7
  170. package/schematics/ng-update/{upgrade-rules/attribute-selectors-rule.d.ts → migrations/attribute-selectors.d.ts} +6 -6
  171. package/schematics/ng-update/migrations/attribute-selectors.js +76 -0
  172. package/schematics/ng-update/{upgrade-rules/class-inheritance-rule.d.ts → migrations/class-inheritance.d.ts} +6 -6
  173. package/schematics/ng-update/migrations/class-inheritance.js +67 -0
  174. package/schematics/ng-update/{upgrade-rules/class-names-rule.d.ts → migrations/class-names.d.ts} +6 -6
  175. package/schematics/ng-update/migrations/class-names.js +98 -0
  176. package/schematics/ng-update/{upgrade-rules/constructor-signature-rule.d.ts → migrations/constructor-signature.d.ts} +6 -6
  177. package/schematics/ng-update/migrations/constructor-signature.js +144 -0
  178. package/schematics/ng-update/{upgrade-rules/css-selectors-rule.d.ts → migrations/css-selectors.d.ts} +6 -6
  179. package/schematics/ng-update/migrations/css-selectors.js +83 -0
  180. package/schematics/ng-update/{upgrade-rules/element-selectors-rule.d.ts → migrations/element-selectors.d.ts} +6 -6
  181. package/schematics/ng-update/migrations/element-selectors.js +74 -0
  182. package/schematics/ng-update/{upgrade-rules/input-names-rule.d.ts → migrations/input-names.d.ts} +6 -6
  183. package/schematics/ng-update/migrations/input-names.js +69 -0
  184. package/schematics/ng-update/{upgrade-rules/method-call-arguments-rule.d.ts → migrations/method-call-arguments.d.ts} +6 -6
  185. package/schematics/ng-update/migrations/method-call-arguments.js +70 -0
  186. package/schematics/ng-update/{upgrade-rules/misc-template-rule.d.ts → migrations/misc-template.d.ts} +6 -6
  187. package/schematics/ng-update/migrations/misc-template.js +47 -0
  188. package/schematics/ng-update/{upgrade-rules/output-names-rule.d.ts → migrations/output-names.d.ts} +6 -6
  189. package/schematics/ng-update/migrations/output-names.js +56 -0
  190. package/schematics/ng-update/{upgrade-rules/property-names-rule.d.ts → migrations/property-names.d.ts} +6 -6
  191. package/schematics/ng-update/migrations/property-names.js +56 -0
  192. package/schematics/ng-update/public-api.d.ts +3 -2
  193. package/schematics/ng-update/public-api.js +5 -4
  194. package/schematics/ng-update/upgrade-data.d.ts +7 -8
  195. package/schematics/ng-update/upgrade-data.js +6 -7
  196. package/schematics/update-tool/component-resource-collector.d.ts +3 -1
  197. package/schematics/update-tool/component-resource-collector.js +8 -8
  198. package/schematics/update-tool/file-system.d.ts +38 -0
  199. package/schematics/update-tool/file-system.js +20 -0
  200. package/schematics/update-tool/index.d.ts +41 -11
  201. package/schematics/update-tool/index.js +135 -106
  202. package/schematics/update-tool/logger.d.ts +16 -0
  203. package/schematics/update-tool/logger.js +27 -0
  204. package/schematics/update-tool/{migration-rule.d.ts → migration.d.ts} +23 -45
  205. package/schematics/update-tool/migration.js +76 -0
  206. package/schematics/update-tool/public-api.d.ts +5 -4
  207. package/schematics/update-tool/public-api.js +6 -6
  208. package/schematics/update-tool/update-recorder.d.ts +14 -0
  209. package/schematics/update-tool/update-recorder.js +20 -0
  210. package/schematics/update-tool/utils/parse-tsconfig.js +1 -1
  211. package/schematics/update-tool/version-changes.js +3 -4
  212. package/schematics/utils/ast/ng-module-imports.js +3 -2
  213. package/scrolling/index.metadata.json +1 -1
  214. package/scrolling/scrolling-module.d.ts +2 -0
  215. package/table/cell.d.ts +2 -0
  216. package/table/index.metadata.json +1 -1
  217. package/table/public-api.d.ts +1 -0
  218. package/table/row.d.ts +6 -3
  219. package/table/table.d.ts +2 -0
  220. package/table/text-column.d.ts +2 -13
  221. package/table/tokens.d.ts +25 -0
  222. package/testing/protractor/protractor-harness-environment.d.ts +10 -3
  223. package/testing/testbed/fake-events/dispatch-events.d.ts +8 -3
  224. package/testing/testbed/fake-events/event-objects.d.ts +12 -1
  225. package/testing/testbed/testbed-harness-environment.d.ts +12 -4
  226. package/tree/index.metadata.json +1 -1
  227. package/tree/padding.d.ts +6 -2
  228. package/schematics/ng-update/upgrade-rules/attribute-selectors-rule.js +0 -76
  229. package/schematics/ng-update/upgrade-rules/class-inheritance-rule.js +0 -67
  230. package/schematics/ng-update/upgrade-rules/class-names-rule.js +0 -96
  231. package/schematics/ng-update/upgrade-rules/constructor-signature-rule.js +0 -144
  232. package/schematics/ng-update/upgrade-rules/css-selectors-rule.js +0 -83
  233. package/schematics/ng-update/upgrade-rules/element-selectors-rule.js +0 -74
  234. package/schematics/ng-update/upgrade-rules/index.d.ts +0 -22
  235. package/schematics/ng-update/upgrade-rules/index.js +0 -116
  236. package/schematics/ng-update/upgrade-rules/input-names-rule.js +0 -69
  237. package/schematics/ng-update/upgrade-rules/method-call-arguments-rule.js +0 -70
  238. package/schematics/ng-update/upgrade-rules/misc-template-rule.js +0 -47
  239. package/schematics/ng-update/upgrade-rules/output-names-rule.js +0 -56
  240. package/schematics/ng-update/upgrade-rules/property-names-rule.js +0 -56
  241. package/schematics/update-tool/migration-rule.js +0 -101
@@ -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(event);
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
- element.addEventListener('mousedown', this._pointerDown, activeEventListenerOptions);
332
- element.addEventListener('touchstart', this._pointerDown, passiveEventListenerOptions);
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
- if (this._dropContainer) {
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
- this._dropContainer.start();
541
- this._initialContainer = this._dropContainer;
542
- this._initialIndex = this._dropContainer.getItemIndex(this);
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.pipe(startWith(null)).subscribe(function () {
593
- _this._scrollPosition = _this._viewportRuler.getViewportScrollPosition();
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.getBoundingClientRect();
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, this._rootElement);
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: '1000'
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 x = point.pageX - referenceRect.left - this._scrollPosition.left;
802
- var y = point.pageY - referenceRect.top - this._scrollPosition.top;
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 - this._scrollPosition.left,
814
- y: point.pageY - this._scrollPosition.top
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 (event) {
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 rootNode = viewRef.rootNodes[0];
1046
- if (rootNode.nodeType !== _document.ELEMENT_NODE) {
1047
- var wrapper = _document.createElement('div');
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
- return rootNode;
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 source Element whose size needs to be matched.
1217
+ * @param sourceRect Dimensions of the source element.
1057
1218
  */
1058
- function matchElementSize(target, source) {
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).appendChild(placeholder);
1323
- activeDraggables.push(item);
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
- this._cacheItems();
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 || !isPointerNearClientRect(this._clientRect, pointerX, pointerY)) {
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 _this = this;
1561
- this._parentPositions.clear();
1562
- this._parentPositions.set(this._document, {
1563
- scrollPosition: this._viewportRuler.getViewportScrollPosition(),
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) { return item.getRootElement().style.transform = ''; });
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 <= Math.floor(clientRect.right) :
1680
- pointerY >= Math.floor(clientRect.top) && pointerY <= Math.floor(clientRect.bottom);
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 target = event.target;
1803
- var position = _this._parentPositions.get(target);
1804
- if (position) {
1805
- var newTop = void 0;
1806
- var newLeft = void 0;
1807
- if (target === _this._document) {
1808
- var scrollPosition = _this._viewportRuler.getViewportScrollPosition();
1809
- newTop = scrollPosition.top;
1810
- newLeft = scrollPosition.left;
1811
- }
1812
- else {
1813
- newTop = target.scrollTop;
1814
- newLeft = target.scrollLeft;
1815
- }
1816
- _this._updateAfterScroll(target, newTop, newLeft);
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,