@angular/cdk 7.0.4 → 7.2.1

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 (271) hide show
  1. package/LICENSE +1 -1
  2. package/_a11y.scss +1 -1
  3. package/a11y/typings/focus-monitor/focus-monitor.d.ts +20 -5
  4. package/a11y/typings/focus-trap/focus-trap.d.ts +2 -0
  5. package/a11y/typings/index.metadata.json +1 -1
  6. package/a11y/typings/live-announcer/live-announcer.d.ts +34 -3
  7. package/bundles/cdk-a11y.umd.js +477 -216
  8. package/bundles/cdk-a11y.umd.js.map +1 -1
  9. package/bundles/cdk-a11y.umd.min.js +1 -1
  10. package/bundles/cdk-a11y.umd.min.js.map +1 -1
  11. package/bundles/cdk-accordion.umd.js +16 -9
  12. package/bundles/cdk-accordion.umd.js.map +1 -1
  13. package/bundles/cdk-accordion.umd.min.js.map +1 -1
  14. package/bundles/cdk-bidi.umd.js +11 -6
  15. package/bundles/cdk-bidi.umd.js.map +1 -1
  16. package/bundles/cdk-bidi.umd.min.js.map +1 -1
  17. package/bundles/cdk-coercion.umd.js +25 -9
  18. package/bundles/cdk-coercion.umd.js.map +1 -1
  19. package/bundles/cdk-coercion.umd.min.js +1 -1
  20. package/bundles/cdk-coercion.umd.min.js.map +1 -1
  21. package/bundles/cdk-collections.umd.js +28 -5
  22. package/bundles/cdk-collections.umd.js.map +1 -1
  23. package/bundles/cdk-collections.umd.min.js.map +1 -1
  24. package/bundles/cdk-drag-drop.umd.js +2177 -915
  25. package/bundles/cdk-drag-drop.umd.js.map +1 -1
  26. package/bundles/cdk-drag-drop.umd.min.js +2 -1
  27. package/bundles/cdk-drag-drop.umd.min.js.map +1 -1
  28. package/bundles/cdk-keycodes.umd.js +33 -1
  29. package/bundles/cdk-keycodes.umd.js.map +1 -1
  30. package/bundles/cdk-keycodes.umd.min.js +1 -1
  31. package/bundles/cdk-keycodes.umd.min.js.map +1 -1
  32. package/bundles/cdk-layout.umd.js +29 -22
  33. package/bundles/cdk-layout.umd.js.map +1 -1
  34. package/bundles/cdk-layout.umd.min.js +1 -1
  35. package/bundles/cdk-layout.umd.min.js.map +1 -1
  36. package/bundles/cdk-observers.umd.js +26 -7
  37. package/bundles/cdk-observers.umd.js.map +1 -1
  38. package/bundles/cdk-observers.umd.min.js +1 -1
  39. package/bundles/cdk-observers.umd.min.js.map +1 -1
  40. package/bundles/cdk-overlay.umd.js +605 -258
  41. package/bundles/cdk-overlay.umd.js.map +1 -1
  42. package/bundles/cdk-overlay.umd.min.js +2 -2
  43. package/bundles/cdk-overlay.umd.min.js.map +1 -1
  44. package/bundles/cdk-platform.umd.js +50 -28
  45. package/bundles/cdk-platform.umd.js.map +1 -1
  46. package/bundles/cdk-platform.umd.min.js.map +1 -1
  47. package/bundles/cdk-portal.umd.js +14 -7
  48. package/bundles/cdk-portal.umd.js.map +1 -1
  49. package/bundles/cdk-portal.umd.min.js.map +1 -1
  50. package/bundles/cdk-scrolling.umd.js +139 -44
  51. package/bundles/cdk-scrolling.umd.js.map +1 -1
  52. package/bundles/cdk-scrolling.umd.min.js +1 -1
  53. package/bundles/cdk-scrolling.umd.min.js.map +1 -1
  54. package/bundles/cdk-stepper.umd.js +103 -19
  55. package/bundles/cdk-stepper.umd.js.map +1 -1
  56. package/bundles/cdk-stepper.umd.min.js +1 -1
  57. package/bundles/cdk-stepper.umd.min.js.map +1 -1
  58. package/bundles/cdk-table.umd.js +182 -48
  59. package/bundles/cdk-table.umd.js.map +1 -1
  60. package/bundles/cdk-table.umd.min.js.map +1 -1
  61. package/bundles/cdk-text-field.umd.js +76 -38
  62. package/bundles/cdk-text-field.umd.js.map +1 -1
  63. package/bundles/cdk-text-field.umd.min.js +1 -1
  64. package/bundles/cdk-text-field.umd.min.js.map +1 -1
  65. package/bundles/cdk-tree.umd.js +71 -34
  66. package/bundles/cdk-tree.umd.js.map +1 -1
  67. package/bundles/cdk-tree.umd.min.js +1 -1
  68. package/bundles/cdk-tree.umd.min.js.map +1 -1
  69. package/bundles/cdk.umd.js +5 -4
  70. package/bundles/cdk.umd.js.map +1 -1
  71. package/bundles/cdk.umd.min.js +1 -1
  72. package/bundles/cdk.umd.min.js.map +1 -1
  73. package/coercion/typings/element.d.ts +13 -0
  74. package/coercion/typings/index.metadata.json +1 -1
  75. package/coercion/typings/public-api.d.ts +1 -0
  76. package/drag-drop/typings/{drag-handle.d.ts → directives/drag-handle.d.ts} +3 -0
  77. package/drag-drop/typings/{drag-placeholder.d.ts → directives/drag-placeholder.d.ts} +0 -0
  78. package/drag-drop/typings/{drag-preview.d.ts → directives/drag-preview.d.ts} +0 -0
  79. package/drag-drop/typings/directives/drag.d.ts +109 -0
  80. package/{typings/drag-drop → drag-drop/typings/directives}/drop-list-group.d.ts +3 -0
  81. package/drag-drop/typings/directives/drop-list.d.ts +135 -0
  82. package/drag-drop/typings/drag-drop-registry.d.ts +8 -3
  83. package/drag-drop/typings/drag-events.d.ts +14 -7
  84. package/{typings/esm5/drag-drop/drag.d.ts → drag-drop/typings/drag-ref.d.ts} +152 -82
  85. package/drag-drop/typings/drop-list-container.d.ts +21 -3
  86. package/drag-drop/typings/{drop-list.d.ts → drop-list-ref.d.ts} +132 -81
  87. package/drag-drop/typings/index.d.ts +1 -0
  88. package/drag-drop/typings/index.metadata.json +1 -1
  89. package/drag-drop/typings/public-api.d.ts +13 -6
  90. package/esm2015/a11y.js +337 -190
  91. package/esm2015/a11y.js.map +1 -1
  92. package/esm2015/accordion.js +16 -11
  93. package/esm2015/accordion.js.map +1 -1
  94. package/esm2015/bidi.js +13 -8
  95. package/esm2015/bidi.js.map +1 -1
  96. package/esm2015/cdk.js +7 -6
  97. package/esm2015/cdk.js.map +1 -1
  98. package/esm2015/coercion.js +25 -8
  99. package/esm2015/coercion.js.map +1 -1
  100. package/esm2015/collections.js +22 -7
  101. package/esm2015/collections.js.map +1 -1
  102. package/esm2015/drag-drop.js +1587 -691
  103. package/esm2015/drag-drop.js.map +1 -1
  104. package/esm2015/keycodes.js +31 -4
  105. package/esm2015/keycodes.js.map +1 -1
  106. package/esm2015/layout.js +29 -19
  107. package/esm2015/layout.js.map +1 -1
  108. package/esm2015/observers.js +15 -10
  109. package/esm2015/observers.js.map +1 -1
  110. package/esm2015/overlay.js +393 -232
  111. package/esm2015/overlay.js.map +1 -1
  112. package/esm2015/platform.js +53 -31
  113. package/esm2015/platform.js.map +1 -1
  114. package/esm2015/portal.js +13 -9
  115. package/esm2015/portal.js.map +1 -1
  116. package/esm2015/scrolling.js +102 -45
  117. package/esm2015/scrolling.js.map +1 -1
  118. package/esm2015/stepper.js +93 -24
  119. package/esm2015/stepper.js.map +1 -1
  120. package/esm2015/table.js +89 -45
  121. package/esm2015/table.js.map +1 -1
  122. package/esm2015/text-field.js +54 -37
  123. package/esm2015/text-field.js.map +1 -1
  124. package/esm2015/tree.js +55 -36
  125. package/esm2015/tree.js.map +1 -1
  126. package/esm5/a11y.es5.js +481 -220
  127. package/esm5/a11y.es5.js.map +1 -1
  128. package/esm5/accordion.es5.js +18 -11
  129. package/esm5/accordion.es5.js.map +1 -1
  130. package/esm5/bidi.es5.js +13 -8
  131. package/esm5/bidi.es5.js.map +1 -1
  132. package/esm5/cdk.es5.js +7 -6
  133. package/esm5/cdk.es5.js.map +1 -1
  134. package/esm5/coercion.es5.js +25 -8
  135. package/esm5/coercion.es5.js.map +1 -1
  136. package/esm5/collections.es5.js +35 -7
  137. package/esm5/collections.es5.js.map +1 -1
  138. package/esm5/drag-drop.es5.js +2233 -972
  139. package/esm5/drag-drop.es5.js.map +1 -1
  140. package/esm5/keycodes.es5.js +35 -4
  141. package/esm5/keycodes.es5.js.map +1 -1
  142. package/esm5/layout.es5.js +31 -24
  143. package/esm5/layout.es5.js.map +1 -1
  144. package/esm5/observers.es5.js +29 -10
  145. package/esm5/observers.es5.js.map +1 -1
  146. package/esm5/overlay.es5.js +609 -262
  147. package/esm5/overlay.es5.js.map +1 -1
  148. package/esm5/platform.es5.js +52 -30
  149. package/esm5/platform.es5.js.map +1 -1
  150. package/esm5/portal.es5.js +16 -9
  151. package/esm5/portal.es5.js.map +1 -1
  152. package/esm5/scrolling.es5.js +141 -46
  153. package/esm5/scrolling.es5.js.map +1 -1
  154. package/esm5/stepper.es5.js +106 -24
  155. package/esm5/stepper.es5.js.map +1 -1
  156. package/esm5/table.es5.js +184 -50
  157. package/esm5/table.es5.js.map +1 -1
  158. package/esm5/text-field.es5.js +75 -37
  159. package/esm5/text-field.es5.js.map +1 -1
  160. package/esm5/tree.es5.js +74 -37
  161. package/esm5/tree.es5.js.map +1 -1
  162. package/keycodes/typings/index.metadata.json +1 -1
  163. package/keycodes/typings/modifiers.d.ts +14 -0
  164. package/keycodes/typings/public-api.d.ts +1 -0
  165. package/overlay/typings/index.metadata.json +1 -1
  166. package/overlay/typings/overlay-directives.d.ts +0 -2
  167. package/package.json +4 -4
  168. package/schematics/ng-generate/drag-drop/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.ts +2 -2
  169. package/schematics/ng-update/upgrade-data.js +2 -1
  170. package/schematics/ng-update/upgrade-data.js.map +1 -1
  171. package/schematics/ng-update/upgrade-rules/index.js +3 -2
  172. package/schematics/ng-update/upgrade-rules/index.js.map +1 -1
  173. package/schematics/utils/ast/ng-module-imports.d.ts +1 -1
  174. package/schematics/utils/ast/ng-module-imports.js +25 -13
  175. package/schematics/utils/ast/ng-module-imports.js.map +1 -1
  176. package/schematics/utils/get-project.js +2 -1
  177. package/schematics/utils/get-project.js.map +1 -1
  178. package/schematics/utils/parse5-element.js +3 -2
  179. package/schematics/utils/parse5-element.js.map +1 -1
  180. package/schematics/utils/project-targets.js +2 -1
  181. package/schematics/utils/project-targets.js.map +1 -1
  182. package/schematics/utils/version-agnostic-typescript.js +3 -2
  183. package/schematics/utils/version-agnostic-typescript.js.map +1 -1
  184. package/scrolling/typings/index.metadata.json +1 -1
  185. package/stepper/typings/index.metadata.json +1 -1
  186. package/stepper/typings/public-api.d.ts +1 -0
  187. package/stepper/typings/step-header.d.ts +15 -0
  188. package/stepper/typings/stepper.d.ts +11 -1
  189. package/text-field/typings/autosize.d.ts +6 -0
  190. package/text-field/typings/index.metadata.json +1 -1
  191. package/tree/typings/control/base-tree-control.d.ts +1 -1
  192. package/tree/typings/control/nested-tree-control.d.ts +2 -2
  193. package/tree/typings/control/tree-control.d.ts +1 -1
  194. package/tree/typings/nested-node.d.ts +5 -5
  195. package/typings/a11y/focus-monitor/focus-monitor.d.ts +20 -5
  196. package/typings/a11y/focus-trap/focus-trap.d.ts +2 -0
  197. package/typings/a11y/index.metadata.json +1 -1
  198. package/typings/a11y/live-announcer/live-announcer.d.ts +34 -3
  199. package/typings/coercion/element.d.ts +13 -0
  200. package/typings/coercion/index.metadata.json +1 -1
  201. package/typings/coercion/public-api.d.ts +1 -0
  202. package/typings/{esm5/drag-drop → drag-drop/directives}/drag-handle.d.ts +3 -0
  203. package/typings/drag-drop/{drag-placeholder.d.ts → directives/drag-placeholder.d.ts} +0 -0
  204. package/typings/drag-drop/{drag-preview.d.ts → directives/drag-preview.d.ts} +0 -0
  205. package/typings/drag-drop/directives/drag.d.ts +109 -0
  206. package/typings/{esm5/drag-drop → drag-drop/directives}/drop-list-group.d.ts +3 -0
  207. package/typings/drag-drop/directives/drop-list.d.ts +135 -0
  208. package/typings/drag-drop/drag-drop-registry.d.ts +8 -3
  209. package/typings/drag-drop/drag-events.d.ts +14 -7
  210. package/typings/drag-drop/{drag.d.ts → drag-ref.d.ts} +152 -82
  211. package/typings/drag-drop/drop-list-container.d.ts +21 -3
  212. package/typings/{esm5/drag-drop/drop-list.d.ts → drag-drop/drop-list-ref.d.ts} +132 -81
  213. package/typings/drag-drop/index.d.ts +1 -0
  214. package/typings/drag-drop/index.metadata.json +1 -1
  215. package/typings/drag-drop/public-api.d.ts +13 -6
  216. package/typings/esm5/a11y/focus-monitor/focus-monitor.d.ts +20 -5
  217. package/typings/esm5/a11y/focus-trap/focus-trap.d.ts +2 -0
  218. package/typings/esm5/a11y/index.metadata.json +1 -1
  219. package/typings/esm5/a11y/live-announcer/live-announcer.d.ts +34 -3
  220. package/typings/esm5/coercion/element.d.ts +13 -0
  221. package/typings/esm5/coercion/index.metadata.json +1 -1
  222. package/typings/esm5/coercion/public-api.d.ts +1 -0
  223. package/typings/{drag-drop → esm5/drag-drop/directives}/drag-handle.d.ts +3 -0
  224. package/typings/esm5/drag-drop/{drag-placeholder.d.ts → directives/drag-placeholder.d.ts} +0 -0
  225. package/typings/esm5/drag-drop/{drag-preview.d.ts → directives/drag-preview.d.ts} +0 -0
  226. package/typings/esm5/drag-drop/directives/drag.d.ts +109 -0
  227. package/{drag-drop/typings → typings/esm5/drag-drop/directives}/drop-list-group.d.ts +3 -0
  228. package/typings/esm5/drag-drop/directives/drop-list.d.ts +135 -0
  229. package/typings/esm5/drag-drop/drag-drop-registry.d.ts +8 -3
  230. package/typings/esm5/drag-drop/drag-events.d.ts +14 -7
  231. package/{drag-drop/typings/drag.d.ts → typings/esm5/drag-drop/drag-ref.d.ts} +152 -82
  232. package/typings/esm5/drag-drop/drop-list-container.d.ts +21 -3
  233. package/typings/{drag-drop/drop-list.d.ts → esm5/drag-drop/drop-list-ref.d.ts} +132 -81
  234. package/typings/esm5/drag-drop/index.d.ts +1 -0
  235. package/typings/esm5/drag-drop/index.metadata.json +1 -1
  236. package/typings/esm5/drag-drop/public-api.d.ts +13 -6
  237. package/typings/esm5/index.metadata.json +1 -1
  238. package/typings/esm5/keycodes/index.metadata.json +1 -1
  239. package/typings/esm5/keycodes/modifiers.d.ts +14 -0
  240. package/typings/esm5/keycodes/public-api.d.ts +1 -0
  241. package/typings/esm5/overlay/index.metadata.json +1 -1
  242. package/typings/esm5/overlay/overlay-directives.d.ts +0 -2
  243. package/typings/esm5/scrolling/index.metadata.json +1 -1
  244. package/typings/esm5/stepper/index.metadata.json +1 -1
  245. package/typings/esm5/stepper/public-api.d.ts +1 -0
  246. package/typings/esm5/stepper/step-header.d.ts +15 -0
  247. package/typings/esm5/stepper/stepper.d.ts +11 -1
  248. package/typings/esm5/text-field/autosize.d.ts +6 -0
  249. package/typings/esm5/text-field/index.metadata.json +1 -1
  250. package/typings/esm5/tree/control/base-tree-control.d.ts +1 -1
  251. package/typings/esm5/tree/control/nested-tree-control.d.ts +2 -2
  252. package/typings/esm5/tree/control/tree-control.d.ts +1 -1
  253. package/typings/esm5/tree/nested-node.d.ts +5 -5
  254. package/typings/index.metadata.json +1 -1
  255. package/typings/keycodes/index.metadata.json +1 -1
  256. package/typings/keycodes/modifiers.d.ts +14 -0
  257. package/typings/keycodes/public-api.d.ts +1 -0
  258. package/typings/overlay/index.metadata.json +1 -1
  259. package/typings/overlay/overlay-directives.d.ts +0 -2
  260. package/typings/schematics/utils/ast/ng-module-imports.d.ts +1 -1
  261. package/typings/scrolling/index.metadata.json +1 -1
  262. package/typings/stepper/index.metadata.json +1 -1
  263. package/typings/stepper/public-api.d.ts +1 -0
  264. package/typings/stepper/step-header.d.ts +15 -0
  265. package/typings/stepper/stepper.d.ts +11 -1
  266. package/typings/text-field/autosize.d.ts +6 -0
  267. package/typings/text-field/index.metadata.json +1 -1
  268. package/typings/tree/control/base-tree-control.d.ts +1 -1
  269. package/typings/tree/control/nested-tree-control.d.ts +2 -2
  270. package/typings/tree/control/tree-control.d.ts +1 -1
  271. package/typings/tree/nested-node.d.ts +5 -5
@@ -5,73 +5,136 @@
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
- import { Injectable, NgZone, Inject, ContentChildren, ElementRef, EventEmitter, forwardRef, Input, Output, Optional, Directive, ChangeDetectorRef, ContentChild, InjectionToken, SkipSelf, ViewContainerRef, TemplateRef, NgModule, defineInjectable, inject } from '@angular/core';
8
+ import { InjectionToken, Injectable, NgZone, Inject, NgModule, ContentChildren, ElementRef, EventEmitter, forwardRef, Input, Output, Optional, Directive, ChangeDetectorRef, SkipSelf, ContentChild, ViewContainerRef, TemplateRef, defineInjectable, inject } from '@angular/core';
9
9
  import { DOCUMENT } from '@angular/common';
10
10
  import { normalizePassiveListenerOptions } from '@angular/cdk/platform';
11
- import { Subject, Observable, Subscription } from 'rxjs';
11
+ import { Subject, Subscription, Observable } from 'rxjs';
12
+ import { coerceBooleanProperty, coerceArray } from '@angular/cdk/coercion';
12
13
  import { Directionality } from '@angular/cdk/bidi';
13
14
  import { ViewportRuler } from '@angular/cdk/scrolling';
14
- import { startWith, take } from 'rxjs/operators';
15
- import { coerceArray } from '@angular/cdk/coercion';
15
+ import { startWith, take, map } from 'rxjs/operators';
16
16
 
17
17
  /**
18
18
  * @fileoverview added by tsickle
19
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
19
+ * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
20
20
  */
21
21
  /**
22
- * Shallow-extends a stylesheet object with another stylesheet object.
23
- * \@docs-private
24
- * @param {?} dest
25
- * @param {?} source
22
+ * Injection token that is used to provide a CdkDropList instance to CdkDrag.
23
+ * Used for avoiding circular imports.
24
+ * @type {?}
25
+ */
26
+ var CDK_DROP_LIST = new InjectionToken('CDK_DROP_LIST');
27
+ /**
28
+ * Injection token that is used to provide a CdkDropList instance to CdkDrag.
29
+ * Used for avoiding circular imports.
30
+ * @deprecated Use `CDK_DROP_LIST` instead.
31
+ * \@breaking-change 8.0.0
32
+ * @type {?}
33
+ */
34
+ var CDK_DROP_LIST_CONTAINER = CDK_DROP_LIST;
35
+
36
+ /**
37
+ * @fileoverview added by tsickle
38
+ * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
39
+ */
40
+
41
+ /**
42
+ * @fileoverview added by tsickle
43
+ * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
44
+ */
45
+
46
+ /**
47
+ * Moves an item one index in an array to another.
48
+ * @template T
49
+ * @param {?} array Array in which to move the item.
50
+ * @param {?} fromIndex Starting index of the item.
51
+ * @param {?} toIndex Index to which the item should be moved.
26
52
  * @return {?}
27
53
  */
28
- function extendStyles(dest, source) {
29
- for (var key in source) {
30
- if (source.hasOwnProperty(key)) {
31
- dest[/** @type {?} */ (key)] = source[/** @type {?} */ (key)];
32
- }
54
+ function moveItemInArray(array, fromIndex, toIndex) {
55
+ /** @type {?} */
56
+ var from = clamp(fromIndex, array.length - 1);
57
+ /** @type {?} */
58
+ var to = clamp(toIndex, array.length - 1);
59
+ if (from === to) {
60
+ return;
33
61
  }
34
- return dest;
62
+ /** @type {?} */
63
+ var target = array[from];
64
+ /** @type {?} */
65
+ var delta = to < from ? -1 : 1;
66
+ for (var i = from; i !== to; i += delta) {
67
+ array[i] = array[i + delta];
68
+ }
69
+ array[to] = target;
35
70
  }
36
71
  /**
37
- * Toggles whether the native drag interactions should be enabled for an element.
38
- * \@docs-private
39
- * @param {?} element Element on which to toggle the drag interactions.
40
- * @param {?} enable Whether the drag interactions should be enabled.
72
+ * Moves an item from one array to another.
73
+ * @template T
74
+ * @param {?} currentArray Array from which to transfer the item.
75
+ * @param {?} targetArray Array into which to put the item.
76
+ * @param {?} currentIndex Index of the item in its current array.
77
+ * @param {?} targetIndex Index at which to insert the item.
41
78
  * @return {?}
42
79
  */
43
- function toggleNativeDragInteractions(element, enable) {
80
+ function transferArrayItem(currentArray, targetArray, currentIndex, targetIndex) {
44
81
  /** @type {?} */
45
- var userSelect = enable ? '' : 'none';
46
- extendStyles(element.style, {
47
- touchAction: enable ? '' : 'none',
48
- webkitUserDrag: enable ? '' : 'none',
49
- webkitTapHighlightColor: enable ? '' : 'transparent',
50
- userSelect: userSelect,
51
- msUserSelect: userSelect,
52
- webkitUserSelect: userSelect,
53
- MozUserSelect: userSelect
54
- });
82
+ var from = clamp(currentIndex, currentArray.length - 1);
83
+ /** @type {?} */
84
+ var to = clamp(targetIndex, targetArray.length);
85
+ if (currentArray.length) {
86
+ targetArray.splice(to, 0, currentArray.splice(from, 1)[0]);
87
+ }
88
+ }
89
+ /**
90
+ * Copies an item from one array to another, leaving it in its
91
+ * original position in current array.
92
+ * @template T
93
+ * @param {?} currentArray Array from which to copy the item.
94
+ * @param {?} targetArray Array into which is copy the item.
95
+ * @param {?} currentIndex Index of the item in its current array.
96
+ * @param {?} targetIndex Index at which to insert the item.
97
+ *
98
+ * @return {?}
99
+ */
100
+ function copyArrayItem(currentArray, targetArray, currentIndex, targetIndex) {
101
+ /** @type {?} */
102
+ var to = clamp(targetIndex, targetArray.length);
103
+ if (currentArray.length) {
104
+ targetArray.splice(to, 0, currentArray[currentIndex]);
105
+ }
106
+ }
107
+ /**
108
+ * Clamps a number between zero and a maximum.
109
+ * @param {?} value
110
+ * @param {?} max
111
+ * @return {?}
112
+ */
113
+ function clamp(value, max) {
114
+ return Math.max(0, Math.min(max, value));
55
115
  }
56
116
 
57
117
  /**
58
118
  * @fileoverview added by tsickle
59
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
119
+ * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
60
120
  */
61
- /** *
121
+ /**
62
122
  * Event options that can be used to bind an active, capturing event.
63
- @type {?} */
123
+ * @type {?}
124
+ */
64
125
  var activeCapturingEventOptions = normalizePassiveListenerOptions({
65
126
  passive: false,
66
127
  capture: true
67
128
  });
68
- // unsupported: template constraints.
69
129
  /**
70
130
  * Service that keeps track of all the drag item and drop container
71
131
  * instances, and manages global event listeners on the `document`.
72
132
  * \@docs-private
73
133
  * @template I, C
74
134
  */
135
+ // Note: this class is generic, rather than referencing CdkDrag and CdkDropList directly, in order
136
+ // to avoid circular imports. If we were to reference them here, importing the registry into the
137
+ // classes that are registering themselves will introduce a circular import.
75
138
  var DragDropRegistry = /** @class */ (function () {
76
139
  function DragDropRegistry(_ngZone, _document) {
77
140
  var _this = this;
@@ -103,9 +166,10 @@ var DragDropRegistry = /** @class */ (function () {
103
166
  */
104
167
  this.pointerUp = new Subject();
105
168
  /**
106
- * Listener used to prevent `touchmove` and `wheel` events while the element is being dragged.
169
+ * Event listener that will prevent the default browser action while the user is dragging.
170
+ * @param event Event whose default action should be prevented.
107
171
  */
108
- this._preventScrollListener = function (event) {
172
+ this._preventDefaultWhileDragging = function (event) {
109
173
  if (_this._activeDragInstances.size) {
110
174
  event.preventDefault();
111
175
  }
@@ -152,7 +216,7 @@ var DragDropRegistry = /** @class */ (function () {
152
216
  this._ngZone.runOutsideAngular(function () {
153
217
  // The event handler has to be explicitly active,
154
218
  // because newer browsers make it passive by default.
155
- _this._document.addEventListener('touchmove', _this._preventScrollListener, activeCapturingEventOptions);
219
+ _this._document.addEventListener('touchmove', _this._preventDefaultWhileDragging, activeCapturingEventOptions);
156
220
  });
157
221
  }
158
222
  };
@@ -185,7 +249,7 @@ var DragDropRegistry = /** @class */ (function () {
185
249
  this._dragInstances.delete(drag);
186
250
  this.stopDragging(drag);
187
251
  if (this._dragInstances.size === 0) {
188
- this._document.removeEventListener('touchmove', this._preventScrollListener, activeCapturingEventOptions);
252
+ this._document.removeEventListener('touchmove', this._preventDefaultWhileDragging, activeCapturingEventOptions);
189
253
  }
190
254
  };
191
255
  /**
@@ -215,26 +279,31 @@ var DragDropRegistry = /** @class */ (function () {
215
279
  var moveEvent = isTouchEvent ? 'touchmove' : 'mousemove';
216
280
  /** @type {?} */
217
281
  var upEvent = isTouchEvent ? 'touchend' : 'mouseup';
218
- // We need to disable the native interactions on the entire body, because
219
- // the user can start marking text if they drag too far in Safari.
220
- toggleNativeDragInteractions(this._document.body, false);
221
282
  // We explicitly bind __active__ listeners here, because newer browsers will default to
222
283
  // passive ones for `mousemove` and `touchmove`. The events need to be active, because we
223
284
  // use `preventDefault` to prevent the page from scrolling while the user is dragging.
224
285
  this._globalListeners
225
286
  .set(moveEvent, {
226
- handler: function (e) { return _this.pointerMove.next(e); },
287
+ handler: function (e) { return _this.pointerMove.next((/** @type {?} */ (e))); },
227
288
  options: activeCapturingEventOptions
228
289
  })
229
290
  .set(upEvent, {
230
- handler: function (e) { return _this.pointerUp.next(e); },
291
+ handler: function (e) { return _this.pointerUp.next((/** @type {?} */ (e))); },
231
292
  options: true
293
+ })
294
+ // Preventing the default action on `mousemove` isn't enough to disable text selection
295
+ // on Safari so we need to prevent the selection event as well. Alternatively this can
296
+ // be done by setting `user-select: none` on the `body`, however it has causes a style
297
+ // recalculation which can be expensive on pages with a lot of elements.
298
+ .set('selectstart', {
299
+ handler: this._preventDefaultWhileDragging,
300
+ options: activeCapturingEventOptions
232
301
  });
233
302
  // TODO(crisbeto): prevent mouse wheel scrolling while
234
303
  // dragging until we've set up proper scroll handling.
235
304
  if (!isTouchEvent) {
236
305
  this._globalListeners.set('wheel', {
237
- handler: this._preventScrollListener,
306
+ handler: this._preventDefaultWhileDragging,
238
307
  options: activeCapturingEventOptions
239
308
  });
240
309
  }
@@ -260,7 +329,6 @@ var DragDropRegistry = /** @class */ (function () {
260
329
  this._activeDragInstances.delete(drag);
261
330
  if (this._activeDragInstances.size === 0) {
262
331
  this._clearGlobalListeners();
263
- toggleNativeDragInteractions(this._document.body, true);
264
332
  }
265
333
  };
266
334
  /** Gets whether a drag item instance is currently being dragged. */
@@ -277,14 +345,22 @@ var DragDropRegistry = /** @class */ (function () {
277
345
  function (drag) {
278
346
  return this._activeDragInstances.has(drag);
279
347
  };
280
- /** Gets a drop container by its id. */
281
348
  /**
282
349
  * Gets a drop container by its id.
350
+ * @deprecated No longer being used. To be removed.
351
+ * @breaking-change 8.0.0
352
+ */
353
+ /**
354
+ * Gets a drop container by its id.
355
+ * @deprecated No longer being used. To be removed.
356
+ * \@breaking-change 8.0.0
283
357
  * @param {?} id
284
358
  * @return {?}
285
359
  */
286
360
  DragDropRegistry.prototype.getDropContainer = /**
287
361
  * Gets a drop container by its id.
362
+ * @deprecated No longer being used. To be removed.
363
+ * \@breaking-change 8.0.0
288
364
  * @param {?} id
289
365
  * @return {?}
290
366
  */
@@ -305,12 +381,15 @@ var DragDropRegistry = /** @class */ (function () {
305
381
  this.pointerMove.complete();
306
382
  this.pointerUp.complete();
307
383
  };
384
+ /** Clears out the global event listeners from the `document`. */
308
385
  /**
309
386
  * Clears out the global event listeners from the `document`.
387
+ * @private
310
388
  * @return {?}
311
389
  */
312
390
  DragDropRegistry.prototype._clearGlobalListeners = /**
313
391
  * Clears out the global event listeners from the `document`.
392
+ * @private
314
393
  * @return {?}
315
394
  */
316
395
  function () {
@@ -334,19 +413,60 @@ var DragDropRegistry = /** @class */ (function () {
334
413
 
335
414
  /**
336
415
  * @fileoverview added by tsickle
337
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
416
+ * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
338
417
  */
339
- /** *
418
+ /**
340
419
  * Injection token that can be used for a `CdkDrag` to provide itself as a parent to the
341
420
  * drag-specific child directive (`CdkDragHandle`, `CdkDragPreview` etc.). Used primarily
342
421
  * to avoid circular imports.
343
422
  * \@docs-private
344
- @type {?} */
423
+ * @type {?}
424
+ */
345
425
  var CDK_DRAG_PARENT = new InjectionToken('CDK_DRAG_PARENT');
346
426
 
347
427
  /**
348
428
  * @fileoverview added by tsickle
349
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
429
+ * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
430
+ */
431
+ /**
432
+ * Shallow-extends a stylesheet object with another stylesheet object.
433
+ * \@docs-private
434
+ * @param {?} dest
435
+ * @param {?} source
436
+ * @return {?}
437
+ */
438
+ function extendStyles(dest, source) {
439
+ for (var key in source) {
440
+ if (source.hasOwnProperty(key)) {
441
+ dest[(/** @type {?} */ (key))] = source[(/** @type {?} */ (key))];
442
+ }
443
+ }
444
+ return dest;
445
+ }
446
+ /**
447
+ * Toggles whether the native drag interactions should be enabled for an element.
448
+ * \@docs-private
449
+ * @param {?} element Element on which to toggle the drag interactions.
450
+ * @param {?} enable Whether the drag interactions should be enabled.
451
+ * @return {?}
452
+ */
453
+ function toggleNativeDragInteractions(element, enable) {
454
+ /** @type {?} */
455
+ var userSelect = enable ? '' : 'none';
456
+ extendStyles(element.style, {
457
+ touchAction: enable ? '' : 'none',
458
+ webkitUserDrag: enable ? '' : 'none',
459
+ webkitTapHighlightColor: enable ? '' : 'transparent',
460
+ userSelect: userSelect,
461
+ msUserSelect: userSelect,
462
+ webkitUserSelect: userSelect,
463
+ MozUserSelect: userSelect
464
+ });
465
+ }
466
+
467
+ /**
468
+ * @fileoverview added by tsickle
469
+ * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
350
470
  */
351
471
  /**
352
472
  * Handle that can be used to drag and CdkDrag instance.
@@ -354,9 +474,27 @@ var CDK_DRAG_PARENT = new InjectionToken('CDK_DRAG_PARENT');
354
474
  var CdkDragHandle = /** @class */ (function () {
355
475
  function CdkDragHandle(element, parentDrag) {
356
476
  this.element = element;
477
+ this._disabled = false;
357
478
  this._parentDrag = parentDrag;
358
479
  toggleNativeDragInteractions(element.nativeElement, false);
359
480
  }
481
+ Object.defineProperty(CdkDragHandle.prototype, "disabled", {
482
+ /** Whether starting to drag through this handle is disabled. */
483
+ get: /**
484
+ * Whether starting to drag through this handle is disabled.
485
+ * @return {?}
486
+ */
487
+ function () { return this._disabled; },
488
+ set: /**
489
+ * @param {?} value
490
+ * @return {?}
491
+ */
492
+ function (value) {
493
+ this._disabled = coerceBooleanProperty(value);
494
+ },
495
+ enumerable: true,
496
+ configurable: true
497
+ });
360
498
  CdkDragHandle.decorators = [
361
499
  { type: Directive, args: [{
362
500
  selector: '[cdkDragHandle]',
@@ -370,12 +508,15 @@ var CdkDragHandle = /** @class */ (function () {
370
508
  { type: ElementRef },
371
509
  { type: undefined, decorators: [{ type: Inject, args: [CDK_DRAG_PARENT,] }, { type: Optional }] }
372
510
  ]; };
511
+ CdkDragHandle.propDecorators = {
512
+ disabled: [{ type: Input, args: ['cdkDragHandleDisabled',] }]
513
+ };
373
514
  return CdkDragHandle;
374
515
  }());
375
516
 
376
517
  /**
377
518
  * @fileoverview added by tsickle
378
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
519
+ * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
379
520
  */
380
521
  /**
381
522
  * Element that will be used as a template for the placeholder of a CdkDrag when
@@ -403,7 +544,7 @@ var CdkDragPlaceholder = /** @class */ (function () {
403
544
 
404
545
  /**
405
546
  * @fileoverview added by tsickle
406
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
547
+ * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
407
548
  */
408
549
  /**
409
550
  * Element that will be used as a template for the preview
@@ -431,17 +572,7 @@ var CdkDragPreview = /** @class */ (function () {
431
572
 
432
573
  /**
433
574
  * @fileoverview added by tsickle
434
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
435
- */
436
- /** *
437
- * Injection token that is used to provide a CdkDropList instance to CdkDrag.
438
- * Used for avoiding circular imports.
439
- @type {?} */
440
- var CDK_DROP_LIST_CONTAINER = new InjectionToken('CDK_DROP_LIST_CONTAINER');
441
-
442
- /**
443
- * @fileoverview added by tsickle
444
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
575
+ * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
445
576
  */
446
577
 
447
578
  /**
@@ -450,6 +581,7 @@ var CDK_DROP_LIST_CONTAINER = new InjectionToken('CDK_DROP_LIST_CONTAINER');
450
581
  * @return {?}
451
582
  */
452
583
  function parseCssTimeUnitsToMs(value) {
584
+ // Some browsers will return it in seconds, whereas others will return milliseconds.
453
585
  /** @type {?} */
454
586
  var multiplier = value.toLowerCase().indexOf('ms') > -1 ? 1 : 1000;
455
587
  return parseFloat(value) * multiplier;
@@ -470,6 +602,8 @@ function getTransformTransitionDurationInMs(element) {
470
602
  if (!property) {
471
603
  return 0;
472
604
  }
605
+ // Get the index of the property that we're interested in and match
606
+ // it up to the same index in `transition-delay` and `transition-duration`.
473
607
  /** @type {?} */
474
608
  var propertyIndex = transitionedProperties.indexOf(property);
475
609
  /** @type {?} */
@@ -493,45 +627,46 @@ function parseCssPropertyValue(computedStyle, name) {
493
627
 
494
628
  /**
495
629
  * @fileoverview added by tsickle
496
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
630
+ * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
497
631
  */
498
- /** *
499
- * Injection token that can be used to configure the behavior of `CdkDrag`.
500
- @type {?} */
501
- var CDK_DRAG_CONFIG = new InjectionToken('CDK_DRAG_CONFIG', {
502
- providedIn: 'root',
503
- factory: CDK_DRAG_CONFIG_FACTORY
504
- });
505
632
  /**
506
- * \@docs-private
507
- * @return {?}
508
- */
509
- function CDK_DRAG_CONFIG_FACTORY() {
510
- return { dragStartThreshold: 5, pointerDirectionChangeThreshold: 5 };
511
- }
512
- /** *
513
633
  * Options that can be used to bind a passive event listener.
514
- @type {?} */
634
+ * @type {?}
635
+ */
515
636
  var passiveEventListenerOptions = normalizePassiveListenerOptions({ passive: true });
516
- /** *
637
+ /**
517
638
  * Options that can be used to bind an active event listener.
518
- @type {?} */
639
+ * @type {?}
640
+ */
519
641
  var activeEventListenerOptions = normalizePassiveListenerOptions({ passive: false });
520
642
  /**
521
- * Element that can be moved inside a CdkDropList container.
643
+ * Time in milliseconds for which to ignore mouse events, after
644
+ * receiving a touch event. Used to avoid doing double work for
645
+ * touch devices where the browser fires fake mouse events, in
646
+ * addition to touch events.
647
+ * @type {?}
648
+ */
649
+ var MOUSE_EVENT_IGNORE_TIME = 800;
650
+ /**
651
+ * Reference to a draggable item. Used to manipulate or dispose of the item.
652
+ * \@docs-private
522
653
  * @template T
523
654
  */
524
- var CdkDrag = /** @class */ (function () {
525
- function CdkDrag(element, /** Droppable container that the draggable is a part of. */
526
- dropContainer, document, _ngZone, _viewContainerRef, _viewportRuler, _dragDropRegistry, _config, _dir) {
655
+ var /**
656
+ * Reference to a draggable item. Used to manipulate or dispose of the item.
657
+ * \@docs-private
658
+ * @template T
659
+ */
660
+ DragRef = /** @class */ (function () {
661
+ function DragRef(element, _document, _ngZone, _viewContainerRef, _viewportRuler, _dragDropRegistry, _config, dropContainer, _dir) {
527
662
  var _this = this;
528
- this.element = element;
529
- this.dropContainer = dropContainer;
663
+ this._document = _document;
530
664
  this._ngZone = _ngZone;
531
665
  this._viewContainerRef = _viewContainerRef;
532
666
  this._viewportRuler = _viewportRuler;
533
667
  this._dragDropRegistry = _dragDropRegistry;
534
668
  this._config = _config;
669
+ this.dropContainer = dropContainer;
535
670
  this._dir = _dir;
536
671
  /**
537
672
  * CSS `transform` applied to the element when it isn't being dragged. We need a
@@ -562,29 +697,46 @@ var CdkDrag = /** @class */ (function () {
562
697
  */
563
698
  this._pointerUpSubscription = Subscription.EMPTY;
564
699
  /**
565
- * Subscription to the stream that initializes the root element.
700
+ * Cached reference to the boundary element.
566
701
  */
567
- this._rootElementInitSubscription = Subscription.EMPTY;
702
+ this._boundaryElement = null;
703
+ /**
704
+ * Whether the native dragging interactions have been enabled on the root element.
705
+ */
706
+ this._nativeInteractionsEnabled = true;
707
+ /**
708
+ * Elements that can be used to drag the draggable item.
709
+ */
710
+ this._handles = [];
711
+ this._disabled = false;
712
+ /**
713
+ * Emits as the drag sequence is being prepared.
714
+ */
715
+ this.beforeStarted = new Subject();
568
716
  /**
569
717
  * Emits when the user starts dragging the item.
570
718
  */
571
- this.started = new EventEmitter();
719
+ this.started = new Subject();
720
+ /**
721
+ * Emits when the user has released a drag item, before any animations have started.
722
+ */
723
+ this.released = new Subject();
572
724
  /**
573
725
  * Emits when the user stops dragging an item in the container.
574
726
  */
575
- this.ended = new EventEmitter();
727
+ this.ended = new Subject();
576
728
  /**
577
729
  * Emits when the user has moved the item into a new container.
578
730
  */
579
- this.entered = new EventEmitter();
731
+ this.entered = new Subject();
580
732
  /**
581
733
  * Emits when the user removes the item its container by dragging it into another container.
582
734
  */
583
- this.exited = new EventEmitter();
735
+ this.exited = new Subject();
584
736
  /**
585
737
  * Emits when the user drops the item inside a container.
586
738
  */
587
- this.dropped = new EventEmitter();
739
+ this.dropped = new Subject();
588
740
  /**
589
741
  * Emits as the user is dragging the item. Use with caution,
590
742
  * because this event will fire for every pixel that the user has dragged.
@@ -602,23 +754,22 @@ var CdkDrag = /** @class */ (function () {
602
754
  * Handler for the `mousedown`/`touchstart` events.
603
755
  */
604
756
  this._pointerDown = function (event) {
605
- /** @type {?} */
606
- var handles = _this.getChildHandles();
757
+ _this.beforeStarted.next();
607
758
  // Delegate the event based on whether it started from a handle or the element itself.
608
- if (handles.length) {
759
+ if (_this._handles.length) {
609
760
  /** @type {?} */
610
- var targetHandle = handles.find(function (handle) {
761
+ var targetHandle = _this._handles.find(function (handle) {
611
762
  /** @type {?} */
612
763
  var element = handle.element.nativeElement;
613
764
  /** @type {?} */
614
765
  var target = event.target;
615
- return !!target && (target === element || element.contains(/** @type {?} */ (target)));
766
+ return !!target && (target === element || element.contains((/** @type {?} */ (target))));
616
767
  });
617
- if (targetHandle) {
768
+ if (targetHandle && !targetHandle.disabled && !_this.disabled) {
618
769
  _this._initializeDragSequence(targetHandle.element.nativeElement, event);
619
770
  }
620
771
  }
621
- else {
772
+ else if (!_this.disabled) {
622
773
  _this._initializeDragSequence(_this._rootElement, event);
623
774
  }
624
775
  };
@@ -626,9 +777,9 @@ var CdkDrag = /** @class */ (function () {
626
777
  * Handler that is invoked when the user moves their pointer after they've initiated a drag.
627
778
  */
628
779
  this._pointerMove = function (event) {
629
- /** @type {?} */
630
- var pointerPosition = _this._getConstrainedPointerPosition(event);
631
780
  if (!_this._hasStartedDragging) {
781
+ /** @type {?} */
782
+ var pointerPosition = _this._getPointerPositionOnPage(event);
632
783
  /** @type {?} */
633
784
  var distanceX = Math.abs(pointerPosition.x - _this._pickupPositionOnPage.x);
634
785
  /** @type {?} */
@@ -639,28 +790,44 @@ var CdkDrag = /** @class */ (function () {
639
790
  // per pixel of movement (e.g. if the user moves their pointer quickly).
640
791
  if (distanceX + distanceY >= _this._config.dragStartThreshold) {
641
792
  _this._hasStartedDragging = true;
642
- _this._ngZone.run(function () { return _this._startDragSequence(); });
793
+ _this._ngZone.run(function () { return _this._startDragSequence(event); });
643
794
  }
644
795
  return;
645
796
  }
797
+ // We only need the preview dimensions if we have a boundary element.
798
+ if (_this._boundaryElement) {
799
+ // Cache the preview element rect if we haven't cached it already or if
800
+ // we cached it too early before the element dimensions were computed.
801
+ if (!_this._previewRect || (!_this._previewRect.width && !_this._previewRect.height)) {
802
+ _this._previewRect = (_this._preview || _this._rootElement).getBoundingClientRect();
803
+ }
804
+ }
805
+ /** @type {?} */
806
+ var constrainedPointerPosition = _this._getConstrainedPointerPosition(event);
646
807
  _this._hasMoved = true;
647
808
  event.preventDefault();
648
- _this._updatePointerDirectionDelta(pointerPosition);
809
+ _this._updatePointerDirectionDelta(constrainedPointerPosition);
649
810
  if (_this.dropContainer) {
650
- _this._updateActiveDropContainer(pointerPosition);
811
+ _this._updateActiveDropContainer(constrainedPointerPosition);
651
812
  }
652
813
  else {
653
814
  /** @type {?} */
654
815
  var activeTransform = _this._activeTransform;
655
816
  activeTransform.x =
656
- pointerPosition.x - _this._pickupPositionOnPage.x + _this._passiveTransform.x;
817
+ constrainedPointerPosition.x - _this._pickupPositionOnPage.x + _this._passiveTransform.x;
657
818
  activeTransform.y =
658
- pointerPosition.y - _this._pickupPositionOnPage.y + _this._passiveTransform.y;
819
+ constrainedPointerPosition.y - _this._pickupPositionOnPage.y + _this._passiveTransform.y;
659
820
  /** @type {?} */
660
821
  var transform = getTransform(activeTransform.x, activeTransform.y);
661
822
  // Preserve the previous `transform` value, if there was one.
662
823
  _this._rootElement.style.transform = _this._initialTransform ?
663
824
  _this._initialTransform + ' ' + transform : transform;
825
+ // Apply transform as attribute if dragging and svg element to work for IE
826
+ if (typeof SVGElement !== 'undefined' && _this._rootElement instanceof SVGElement) {
827
+ /** @type {?} */
828
+ var appliedTransform = "translate(" + activeTransform.x + " " + activeTransform.y + ")";
829
+ _this._rootElement.setAttribute('transform', appliedTransform);
830
+ }
664
831
  }
665
832
  // Since this event gets fired for every pixel while dragging, we only
666
833
  // want to fire it if the consumer opted into it. Also we have to
@@ -669,7 +836,7 @@ var CdkDrag = /** @class */ (function () {
669
836
  _this._ngZone.run(function () {
670
837
  _this._moveEvents.next({
671
838
  source: _this,
672
- pointerPosition: pointerPosition,
839
+ pointerPosition: constrainedPointerPosition,
673
840
  event: event,
674
841
  delta: _this._pointerDirectionDelta
675
842
  });
@@ -679,29 +846,65 @@ var CdkDrag = /** @class */ (function () {
679
846
  /**
680
847
  * Handler that is invoked when the user lifts their pointer up, after initiating a drag.
681
848
  */
682
- this._pointerUp = function () {
683
- if (!_this._isDragging()) {
849
+ this._pointerUp = function (event) {
850
+ // Note that here we use `isDragging` from the service, rather than from `this`.
851
+ // The difference is that the one from the service reflects whether a dragging sequence
852
+ // has been initiated, whereas the one on `this` includes whether the user has passed
853
+ // the minimum dragging threshold.
854
+ if (!_this._dragDropRegistry.isDragging(_this)) {
684
855
  return;
685
856
  }
686
857
  _this._removeSubscriptions();
687
858
  _this._dragDropRegistry.stopDragging(_this);
859
+ if (_this._handles) {
860
+ _this._rootElement.style.webkitTapHighlightColor = _this._rootElementTapHighlight;
861
+ }
688
862
  if (!_this._hasStartedDragging) {
689
863
  return;
690
864
  }
865
+ _this.released.next({ source: _this });
691
866
  if (!_this.dropContainer) {
692
867
  // Convert the active transform into a passive one. This means that next time
693
868
  // the user starts dragging the item, its position will be calculated relatively
694
869
  // to the new passive transform.
695
870
  _this._passiveTransform.x = _this._activeTransform.x;
696
871
  _this._passiveTransform.y = _this._activeTransform.y;
697
- _this._ngZone.run(function () { return _this.ended.emit({ source: _this }); });
872
+ _this._ngZone.run(function () { return _this.ended.next({ source: _this }); });
873
+ _this._dragDropRegistry.stopDragging(_this);
698
874
  return;
699
875
  }
700
- _this._animatePreviewToPlaceholder().then(function () { return _this._cleanupDragArtifacts(); });
876
+ _this._animatePreviewToPlaceholder().then(function () {
877
+ _this._cleanupDragArtifacts(event);
878
+ _this._dragDropRegistry.stopDragging(_this);
879
+ });
701
880
  };
702
- this._document = document;
881
+ this.withRootElement(element);
703
882
  _dragDropRegistry.registerDragItem(this);
704
883
  }
884
+ Object.defineProperty(DragRef.prototype, "disabled", {
885
+ /** Whether starting to drag this element is disabled. */
886
+ get: /**
887
+ * Whether starting to drag this element is disabled.
888
+ * @return {?}
889
+ */
890
+ function () {
891
+ return this._disabled || !!(this.dropContainer && this.dropContainer.disabled);
892
+ },
893
+ set: /**
894
+ * @param {?} value
895
+ * @return {?}
896
+ */
897
+ function (value) {
898
+ /** @type {?} */
899
+ var newValue = coerceBooleanProperty(value);
900
+ if (newValue !== this._disabled) {
901
+ this._disabled = newValue;
902
+ this._toggleNativeDragInteractions();
903
+ }
904
+ },
905
+ enumerable: true,
906
+ configurable: true
907
+ });
705
908
  /**
706
909
  * Returns the element that is being used as a placeholder
707
910
  * while the current element is being dragged.
@@ -711,7 +914,7 @@ var CdkDrag = /** @class */ (function () {
711
914
  * while the current element is being dragged.
712
915
  * @return {?}
713
916
  */
714
- CdkDrag.prototype.getPlaceholderElement = /**
917
+ DragRef.prototype.getPlaceholderElement = /**
715
918
  * Returns the element that is being used as a placeholder
716
919
  * while the current element is being dragged.
717
920
  * @return {?}
@@ -724,112 +927,304 @@ var CdkDrag = /** @class */ (function () {
724
927
  * Returns the root draggable element.
725
928
  * @return {?}
726
929
  */
727
- CdkDrag.prototype.getRootElement = /**
930
+ DragRef.prototype.getRootElement = /**
728
931
  * Returns the root draggable element.
729
932
  * @return {?}
730
933
  */
731
934
  function () {
732
935
  return this._rootElement;
733
936
  };
734
- /** Resets a standalone drag item to its initial position. */
937
+ /** Registers the handles that can be used to drag the element. */
735
938
  /**
736
- * Resets a standalone drag item to its initial position.
939
+ * Registers the handles that can be used to drag the element.
940
+ * @template THIS
941
+ * @this {THIS}
942
+ * @param {?} handles
943
+ * @return {THIS}
944
+ */
945
+ DragRef.prototype.withHandles = /**
946
+ * Registers the handles that can be used to drag the element.
947
+ * @template THIS
948
+ * @this {THIS}
949
+ * @param {?} handles
950
+ * @return {THIS}
951
+ */
952
+ function (handles) {
953
+ // TODO(crisbeto): have this accept HTMLElement[] | ElementRef<HTMLElement>[]
954
+ (/** @type {?} */ (this))._handles = handles;
955
+ handles.forEach(function (handle) { return toggleNativeDragInteractions(handle.element.nativeElement, false); });
956
+ (/** @type {?} */ (this))._toggleNativeDragInteractions();
957
+ return (/** @type {?} */ (this));
958
+ };
959
+ /** Registers the template that should be used for the drag preview. */
960
+ /**
961
+ * Registers the template that should be used for the drag preview.
962
+ * @template THIS
963
+ * @this {THIS}
964
+ * @param {?} template
965
+ * @return {THIS}
966
+ */
967
+ DragRef.prototype.withPreviewTemplate = /**
968
+ * Registers the template that should be used for the drag preview.
969
+ * @template THIS
970
+ * @this {THIS}
971
+ * @param {?} template
972
+ * @return {THIS}
973
+ */
974
+ function (template) {
975
+ // TODO(crisbeto): have this accept a TemplateRef
976
+ (/** @type {?} */ (this))._previewTemplate = template;
977
+ return (/** @type {?} */ (this));
978
+ };
979
+ /** Registers the template that should be used for the drag placeholder. */
980
+ /**
981
+ * Registers the template that should be used for the drag placeholder.
982
+ * @template THIS
983
+ * @this {THIS}
984
+ * @param {?} template
985
+ * @return {THIS}
986
+ */
987
+ DragRef.prototype.withPlaceholderTemplate = /**
988
+ * Registers the template that should be used for the drag placeholder.
989
+ * @template THIS
990
+ * @this {THIS}
991
+ * @param {?} template
992
+ * @return {THIS}
993
+ */
994
+ function (template) {
995
+ // TODO(crisbeto): have this accept a TemplateRef
996
+ (/** @type {?} */ (this))._placeholderTemplate = template;
997
+ return (/** @type {?} */ (this));
998
+ };
999
+ /**
1000
+ * Sets an alternate drag root element. The root element is the element that will be moved as
1001
+ * the user is dragging. Passing an alternate root element is useful when trying to enable
1002
+ * dragging on an element that you might not have access to.
1003
+ */
1004
+ /**
1005
+ * Sets an alternate drag root element. The root element is the element that will be moved as
1006
+ * the user is dragging. Passing an alternate root element is useful when trying to enable
1007
+ * dragging on an element that you might not have access to.
1008
+ * @template THIS
1009
+ * @this {THIS}
1010
+ * @param {?} rootElement
1011
+ * @return {THIS}
1012
+ */
1013
+ DragRef.prototype.withRootElement = /**
1014
+ * Sets an alternate drag root element. The root element is the element that will be moved as
1015
+ * the user is dragging. Passing an alternate root element is useful when trying to enable
1016
+ * dragging on an element that you might not have access to.
1017
+ * @template THIS
1018
+ * @this {THIS}
1019
+ * @param {?} rootElement
1020
+ * @return {THIS}
1021
+ */
1022
+ function (rootElement) {
1023
+ /** @type {?} */
1024
+ var element = rootElement instanceof ElementRef ? rootElement.nativeElement : rootElement;
1025
+ if (element !== (/** @type {?} */ (this))._rootElement) {
1026
+ if ((/** @type {?} */ (this))._rootElement) {
1027
+ (/** @type {?} */ (this))._removeRootElementListeners((/** @type {?} */ (this))._rootElement);
1028
+ }
1029
+ element.addEventListener('mousedown', (/** @type {?} */ (this))._pointerDown, activeEventListenerOptions);
1030
+ element.addEventListener('touchstart', (/** @type {?} */ (this))._pointerDown, passiveEventListenerOptions);
1031
+ (/** @type {?} */ (this))._rootElement = element;
1032
+ }
1033
+ return (/** @type {?} */ (this));
1034
+ };
1035
+ /**
1036
+ * Element to which the draggable's position will be constrained.
1037
+ */
1038
+ /**
1039
+ * Element to which the draggable's position will be constrained.
1040
+ * @template THIS
1041
+ * @this {THIS}
1042
+ * @param {?} boundaryElement
1043
+ * @return {THIS}
1044
+ */
1045
+ DragRef.prototype.withBoundaryElement = /**
1046
+ * Element to which the draggable's position will be constrained.
1047
+ * @template THIS
1048
+ * @this {THIS}
1049
+ * @param {?} boundaryElement
1050
+ * @return {THIS}
1051
+ */
1052
+ function (boundaryElement) {
1053
+ (/** @type {?} */ (this))._boundaryElement = boundaryElement instanceof ElementRef ?
1054
+ boundaryElement.nativeElement : boundaryElement;
1055
+ return (/** @type {?} */ (this));
1056
+ };
1057
+ /** Removes the dragging functionality from the DOM element. */
1058
+ /**
1059
+ * Removes the dragging functionality from the DOM element.
737
1060
  * @return {?}
738
1061
  */
739
- CdkDrag.prototype.reset = /**
740
- * Resets a standalone drag item to its initial position.
1062
+ DragRef.prototype.dispose = /**
1063
+ * Removes the dragging functionality from the DOM element.
741
1064
  * @return {?}
742
1065
  */
743
1066
  function () {
744
- this._rootElement.style.transform = '';
745
- this._activeTransform = { x: 0, y: 0 };
746
- this._passiveTransform = { x: 0, y: 0 };
1067
+ this._removeRootElementListeners(this._rootElement);
1068
+ // Do this check before removing from the registry since it'll
1069
+ // stop being considered as dragged once it is removed.
1070
+ if (this.isDragging()) {
1071
+ // Since we move out the element to the end of the body while it's being
1072
+ // dragged, we have to make sure that it's removed if it gets destroyed.
1073
+ removeElement(this._rootElement);
1074
+ }
1075
+ this._destroyPreview();
1076
+ this._destroyPlaceholder();
1077
+ this._dragDropRegistry.removeDragItem(this);
1078
+ this._removeSubscriptions();
1079
+ this.beforeStarted.complete();
1080
+ this.started.complete();
1081
+ this.released.complete();
1082
+ this.ended.complete();
1083
+ this.entered.complete();
1084
+ this.exited.complete();
1085
+ this.dropped.complete();
1086
+ this._moveEvents.complete();
1087
+ this._handles = [];
1088
+ this._boundaryElement = this._rootElement = this._placeholderTemplate =
1089
+ this._previewTemplate = this._nextSibling = (/** @type {?} */ (null));
747
1090
  };
1091
+ /** Checks whether the element is currently being dragged. */
748
1092
  /**
1093
+ * Checks whether the element is currently being dragged.
749
1094
  * @return {?}
750
1095
  */
751
- CdkDrag.prototype.ngAfterViewInit = /**
1096
+ DragRef.prototype.isDragging = /**
1097
+ * Checks whether the element is currently being dragged.
752
1098
  * @return {?}
753
1099
  */
754
1100
  function () {
755
- var _this = this;
756
- // We need to wait for the zone to stabilize, in order for the reference
757
- // element to be in the proper place in the DOM. This is mostly relevant
758
- // for draggable elements inside portals since they get stamped out in
759
- // their original DOM position and then they get transferred to the portal.
760
- this._rootElementInitSubscription = this._ngZone.onStable.asObservable()
761
- .pipe(take(1))
762
- .subscribe(function () {
763
- /** @type {?} */
764
- var rootElement = _this._rootElement = _this._getRootElement();
765
- rootElement.addEventListener('mousedown', _this._pointerDown, activeEventListenerOptions);
766
- rootElement.addEventListener('touchstart', _this._pointerDown, passiveEventListenerOptions);
767
- _this._handles.changes.pipe(startWith(null)).subscribe(function () {
768
- return toggleNativeDragInteractions(rootElement, _this.getChildHandles().length > 0);
769
- });
770
- });
1101
+ return this._hasStartedDragging && this._dragDropRegistry.isDragging(this);
771
1102
  };
1103
+ /** Resets a standalone drag item to its initial position. */
772
1104
  /**
1105
+ * Resets a standalone drag item to its initial position.
773
1106
  * @return {?}
774
1107
  */
775
- CdkDrag.prototype.ngOnDestroy = /**
1108
+ DragRef.prototype.reset = /**
1109
+ * Resets a standalone drag item to its initial position.
776
1110
  * @return {?}
777
1111
  */
778
1112
  function () {
779
- // The directive might have been destroyed before the root element is initialized.
780
- if (this._rootElement) {
781
- this._rootElement.removeEventListener('mousedown', this._pointerDown, activeEventListenerOptions);
782
- this._rootElement.removeEventListener('touchstart', this._pointerDown, passiveEventListenerOptions);
783
- // Do this check before removing from the registry since it'll
784
- // stop being considered as dragged once it is removed.
785
- if (this._isDragging()) {
786
- // Since we move out the element to the end of the body while it's being
787
- // dragged, we have to make sure that it's removed if it gets destroyed.
788
- this._removeElement(this._rootElement);
789
- }
790
- }
791
- this._rootElementInitSubscription.unsubscribe();
792
- this._destroyPreview();
793
- this._destroyPlaceholder();
794
- this._nextSibling = null;
795
- this._dragDropRegistry.removeDragItem(this);
796
- this._removeSubscriptions();
797
- this._moveEvents.complete();
1113
+ this._rootElement.style.transform = '';
1114
+ this._activeTransform = { x: 0, y: 0 };
1115
+ this._passiveTransform = { x: 0, y: 0 };
798
1116
  };
799
- /** Checks whether the element is currently being dragged. */
1117
+ /** Unsubscribes from the global subscriptions. */
800
1118
  /**
801
- * Checks whether the element is currently being dragged.
1119
+ * Unsubscribes from the global subscriptions.
1120
+ * @private
802
1121
  * @return {?}
803
1122
  */
804
- CdkDrag.prototype._isDragging = /**
805
- * Checks whether the element is currently being dragged.
1123
+ DragRef.prototype._removeSubscriptions = /**
1124
+ * Unsubscribes from the global subscriptions.
1125
+ * @private
806
1126
  * @return {?}
807
1127
  */
808
1128
  function () {
809
- return this._dragDropRegistry.isDragging(this);
1129
+ this._pointerMoveSubscription.unsubscribe();
1130
+ this._pointerUpSubscription.unsubscribe();
810
1131
  };
1132
+ /** Destroys the preview element and its ViewRef. */
811
1133
  /**
812
- * Gets only handles that are not inside descendant `CdkDrag` instances.
1134
+ * Destroys the preview element and its ViewRef.
1135
+ * @private
813
1136
  * @return {?}
814
1137
  */
815
- CdkDrag.prototype.getChildHandles = /**
816
- * Gets only handles that are not inside descendant `CdkDrag` instances.
1138
+ DragRef.prototype._destroyPreview = /**
1139
+ * Destroys the preview element and its ViewRef.
1140
+ * @private
817
1141
  * @return {?}
818
1142
  */
819
1143
  function () {
820
- var _this = this;
821
- return this._handles.filter(function (handle) { return handle._parentDrag === _this; });
1144
+ if (this._preview) {
1145
+ removeElement(this._preview);
1146
+ }
1147
+ if (this._previewRef) {
1148
+ this._previewRef.destroy();
1149
+ }
1150
+ this._preview = this._previewRef = (/** @type {?} */ (null));
1151
+ };
1152
+ /** Destroys the placeholder element and its ViewRef. */
1153
+ /**
1154
+ * Destroys the placeholder element and its ViewRef.
1155
+ * @private
1156
+ * @return {?}
1157
+ */
1158
+ DragRef.prototype._destroyPlaceholder = /**
1159
+ * Destroys the placeholder element and its ViewRef.
1160
+ * @private
1161
+ * @return {?}
1162
+ */
1163
+ function () {
1164
+ if (this._placeholder) {
1165
+ removeElement(this._placeholder);
1166
+ }
1167
+ if (this._placeholderRef) {
1168
+ this._placeholderRef.destroy();
1169
+ }
1170
+ this._placeholder = this._placeholderRef = (/** @type {?} */ (null));
1171
+ };
1172
+ /** Starts the dragging sequence. */
1173
+ /**
1174
+ * Starts the dragging sequence.
1175
+ * @private
1176
+ * @param {?} event
1177
+ * @return {?}
1178
+ */
1179
+ DragRef.prototype._startDragSequence = /**
1180
+ * Starts the dragging sequence.
1181
+ * @private
1182
+ * @param {?} event
1183
+ * @return {?}
1184
+ */
1185
+ function (event) {
1186
+ // Emit the event on the item before the one on the container.
1187
+ this.started.next({ source: this });
1188
+ if (isTouchEvent(event)) {
1189
+ this._lastTouchEventTime = Date.now();
1190
+ }
1191
+ if (this.dropContainer) {
1192
+ /** @type {?} */
1193
+ var element = this._rootElement;
1194
+ // Grab the `nextSibling` before the preview and placeholder
1195
+ // have been created so we don't get the preview by accident.
1196
+ this._nextSibling = element.nextSibling;
1197
+ /** @type {?} */
1198
+ var preview = this._preview = this._createPreviewElement();
1199
+ /** @type {?} */
1200
+ var placeholder = this._placeholder = this._createPlaceholderElement();
1201
+ // We move the element out at the end of the body and we make it hidden, because keeping it in
1202
+ // place will throw off the consumer's `:last-child` selectors. We can't remove the element
1203
+ // from the DOM completely, because iOS will stop firing all subsequent events in the chain.
1204
+ element.style.display = 'none';
1205
+ this._document.body.appendChild((/** @type {?} */ (element.parentNode)).replaceChild(placeholder, element));
1206
+ this._document.body.appendChild(preview);
1207
+ this.dropContainer.start();
1208
+ }
822
1209
  };
823
1210
  /**
824
1211
  * Sets up the different variables and subscriptions
825
1212
  * that will be necessary for the dragging sequence.
1213
+ * @param referenceElement Element that started the drag sequence.
1214
+ * @param event Browser event object that started the sequence.
1215
+ */
1216
+ /**
1217
+ * Sets up the different variables and subscriptions
1218
+ * that will be necessary for the dragging sequence.
1219
+ * @private
826
1220
  * @param {?} referenceElement Element that started the drag sequence.
827
1221
  * @param {?} event Browser event object that started the sequence.
828
1222
  * @return {?}
829
1223
  */
830
- CdkDrag.prototype._initializeDragSequence = /**
1224
+ DragRef.prototype._initializeDragSequence = /**
831
1225
  * Sets up the different variables and subscriptions
832
1226
  * that will be necessary for the dragging sequence.
1227
+ * @private
833
1228
  * @param {?} referenceElement Element that started the drag sequence.
834
1229
  * @param {?} event Browser event object that started the sequence.
835
1230
  * @return {?}
@@ -839,17 +1234,28 @@ var CdkDrag = /** @class */ (function () {
839
1234
  // the dragging sequence, in order to prevent it from potentially
840
1235
  // starting another sequence for a draggable parent somewhere up the DOM tree.
841
1236
  event.stopPropagation();
1237
+ /** @type {?} */
1238
+ var isDragging = this.isDragging();
1239
+ /** @type {?} */
1240
+ var isTouchSequence = isTouchEvent(event);
1241
+ /** @type {?} */
1242
+ var isAuxiliaryMouseButton = !isTouchSequence && ((/** @type {?} */ (event))).button !== 0;
1243
+ /** @type {?} */
1244
+ var rootElement = this._rootElement;
1245
+ /** @type {?} */
1246
+ var isSyntheticEvent = !isTouchSequence && this._lastTouchEventTime &&
1247
+ this._lastTouchEventTime + MOUSE_EVENT_IGNORE_TIME > Date.now();
842
1248
  // If the event started from an element with the native HTML drag&drop, it'll interfere
843
1249
  // with our own dragging (e.g. `img` tags do it by default). Prevent the default action
844
1250
  // to stop it from happening. Note that preventing on `dragstart` also seems to work, but
845
1251
  // it's flaky and it fails if the user drags it away quickly. Also note that we only want
846
1252
  // to do this for `mousedown` since doing the same for `touchstart` will stop any `click`
847
1253
  // events from firing on touch devices.
848
- if (event.target && (/** @type {?} */ (event.target)).draggable && event.type === 'mousedown') {
1254
+ if (event.target && ((/** @type {?} */ (event.target))).draggable && event.type === 'mousedown') {
849
1255
  event.preventDefault();
850
1256
  }
851
1257
  // Abort if the user is already dragging or is using a mouse button other than the primary one.
852
- if (this._isDragging() || (!this._isTouchEvent(event) && event.button !== 0)) {
1258
+ if (isDragging || isAuxiliaryMouseButton || isSyntheticEvent) {
853
1259
  return;
854
1260
  }
855
1261
  // Cache the previous transform amount only after the first drag sequence, because
@@ -857,11 +1263,22 @@ var CdkDrag = /** @class */ (function () {
857
1263
  if (this._initialTransform == null) {
858
1264
  this._initialTransform = this._rootElement.style.transform || '';
859
1265
  }
1266
+ // If we've got handles, we need to disable the tap highlight on the entire root element,
1267
+ // otherwise iOS will still add it, even though all the drag interactions on the handle
1268
+ // are disabled.
1269
+ if (this._handles.length) {
1270
+ this._rootElementTapHighlight = rootElement.style.webkitTapHighlightColor;
1271
+ rootElement.style.webkitTapHighlightColor = 'transparent';
1272
+ }
1273
+ this._toggleNativeDragInteractions();
860
1274
  this._hasStartedDragging = this._hasMoved = false;
861
- this._initialContainer = this.dropContainer;
1275
+ this._initialContainer = (/** @type {?} */ (this.dropContainer));
862
1276
  this._pointerMoveSubscription = this._dragDropRegistry.pointerMove.subscribe(this._pointerMove);
863
1277
  this._pointerUpSubscription = this._dragDropRegistry.pointerUp.subscribe(this._pointerUp);
864
1278
  this._scrollPosition = this._viewportRuler.getViewportScrollPosition();
1279
+ if (this._boundaryElement) {
1280
+ this._boundaryRect = this._boundaryElement.getBoundingClientRect();
1281
+ }
865
1282
  // If we have a custom preview template, the element won't be visible anyway so we avoid the
866
1283
  // extra `getBoundingClientRect` calls and just move the preview next to the cursor.
867
1284
  this._pickupPositionInElement = this._previewTemplate ? { x: 0, y: 0 } :
@@ -872,45 +1289,20 @@ var CdkDrag = /** @class */ (function () {
872
1289
  this._pointerPositionAtLastDirectionChange = { x: pointerPosition.x, y: pointerPosition.y };
873
1290
  this._dragDropRegistry.startDragging(this, event);
874
1291
  };
875
- /**
876
- * Starts the dragging sequence.
877
- * @return {?}
878
- */
879
- CdkDrag.prototype._startDragSequence = /**
880
- * Starts the dragging sequence.
881
- * @return {?}
882
- */
883
- function () {
884
- // Emit the event on the item before the one on the container.
885
- this.started.emit({ source: this });
886
- if (this.dropContainer) {
887
- /** @type {?} */
888
- var element = this._rootElement;
889
- // Grab the `nextSibling` before the preview and placeholder
890
- // have been created so we don't get the preview by accident.
891
- this._nextSibling = element.nextSibling;
892
- /** @type {?} */
893
- var preview = this._preview = this._createPreviewElement();
894
- /** @type {?} */
895
- var placeholder = this._placeholder = this._createPlaceholderElement();
896
- // We move the element out at the end of the body and we make it hidden, because keeping it in
897
- // place will throw off the consumer's `:last-child` selectors. We can't remove the element
898
- // from the DOM completely, because iOS will stop firing all subsequent events in the chain.
899
- element.style.display = 'none';
900
- this._document.body.appendChild(/** @type {?} */ ((element.parentNode)).replaceChild(placeholder, element));
901
- this._document.body.appendChild(preview);
902
- this.dropContainer.start();
903
- }
904
- };
1292
+ /** Cleans up the DOM artifacts that were added to facilitate the element being dragged. */
905
1293
  /**
906
1294
  * Cleans up the DOM artifacts that were added to facilitate the element being dragged.
1295
+ * @private
1296
+ * @param {?} event
907
1297
  * @return {?}
908
1298
  */
909
- CdkDrag.prototype._cleanupDragArtifacts = /**
1299
+ DragRef.prototype._cleanupDragArtifacts = /**
910
1300
  * Cleans up the DOM artifacts that were added to facilitate the element being dragged.
1301
+ * @private
1302
+ * @param {?} event
911
1303
  * @return {?}
912
1304
  */
913
- function () {
1305
+ function (event) {
914
1306
  var _this = this;
915
1307
  // Restore the element's visibility and insert it at its old position in the DOM.
916
1308
  // It's important that we maintain the position, because moving the element around in the DOM
@@ -918,77 +1310,97 @@ var CdkDrag = /** @class */ (function () {
918
1310
  // while moving the existing elements in all other cases.
919
1311
  this._rootElement.style.display = '';
920
1312
  if (this._nextSibling) {
921
- /** @type {?} */ ((this._nextSibling.parentNode)).insertBefore(this._rootElement, this._nextSibling);
1313
+ (/** @type {?} */ (this._nextSibling.parentNode)).insertBefore(this._rootElement, this._nextSibling);
922
1314
  }
923
1315
  else {
924
1316
  this._initialContainer.element.nativeElement.appendChild(this._rootElement);
925
1317
  }
926
1318
  this._destroyPreview();
927
1319
  this._destroyPlaceholder();
1320
+ this._boundaryRect = this._previewRect = undefined;
928
1321
  // Re-enter the NgZone since we bound `document` events on the outside.
929
1322
  this._ngZone.run(function () {
930
1323
  /** @type {?} */
931
- var currentIndex = _this.dropContainer.getItemIndex(_this);
932
- _this.ended.emit({ source: _this });
933
- _this.dropped.emit({
1324
+ var container = (/** @type {?} */ (_this.dropContainer));
1325
+ /** @type {?} */
1326
+ var currentIndex = container.getItemIndex(_this);
1327
+ var _a = _this._getPointerPositionOnPage(event), x = _a.x, y = _a.y;
1328
+ /** @type {?} */
1329
+ var isPointerOverContainer = container._isOverContainer(x, y);
1330
+ _this.ended.next({ source: _this });
1331
+ _this.dropped.next({
934
1332
  item: _this,
935
1333
  currentIndex: currentIndex,
936
1334
  previousIndex: _this._initialContainer.getItemIndex(_this),
937
- container: _this.dropContainer,
938
- previousContainer: _this._initialContainer
1335
+ container: container,
1336
+ previousContainer: _this._initialContainer,
1337
+ isPointerOverContainer: isPointerOverContainer
939
1338
  });
940
- _this.dropContainer.drop(_this, currentIndex, _this._initialContainer);
1339
+ container.drop(_this, currentIndex, _this._initialContainer, isPointerOverContainer);
941
1340
  _this.dropContainer = _this._initialContainer;
942
1341
  });
943
1342
  };
944
1343
  /**
945
1344
  * Updates the item's position in its drop container, or moves it
946
1345
  * into a new one, depending on its current drag position.
1346
+ */
1347
+ /**
1348
+ * Updates the item's position in its drop container, or moves it
1349
+ * into a new one, depending on its current drag position.
1350
+ * @private
947
1351
  * @param {?} __0
948
1352
  * @return {?}
949
1353
  */
950
- CdkDrag.prototype._updateActiveDropContainer = /**
1354
+ DragRef.prototype._updateActiveDropContainer = /**
951
1355
  * Updates the item's position in its drop container, or moves it
952
1356
  * into a new one, depending on its current drag position.
1357
+ * @private
953
1358
  * @param {?} __0
954
1359
  * @return {?}
955
1360
  */
956
1361
  function (_a) {
957
1362
  var _this = this;
958
1363
  var x = _a.x, y = _a.y;
1364
+ // Drop container that draggable has been moved into.
959
1365
  /** @type {?} */
960
- var newContainer = this.dropContainer._getSiblingContainerFromPosition(this, x, y);
1366
+ var newContainer = (/** @type {?} */ (this.dropContainer))._getSiblingContainerFromPosition(this, x, y);
961
1367
  // If we couldn't find a new container to move the item into, and the item has left it's
962
- // initial container, check whether the it's allowed to return into its original container.
963
- // This handles the case where two containers are connected one way and the user tries to
964
- // undo dragging an item into a new container.
1368
+ // initial container, check whether the it's over the initial container. This handles the
1369
+ // case where two containers are connected one way and the user tries to undo dragging an
1370
+ // item into a new container.
965
1371
  if (!newContainer && this.dropContainer !== this._initialContainer &&
966
- this._initialContainer._canReturnItem(x, y)) {
1372
+ this._initialContainer._isOverContainer(x, y)) {
967
1373
  newContainer = this._initialContainer;
968
1374
  }
969
1375
  if (newContainer) {
970
1376
  this._ngZone.run(function () {
971
1377
  // Notify the old container that the item has left.
972
- _this.exited.emit({ item: _this, container: _this.dropContainer });
973
- _this.dropContainer.exit(_this);
1378
+ _this.exited.next({ item: _this, container: (/** @type {?} */ (_this.dropContainer)) });
1379
+ (/** @type {?} */ (_this.dropContainer)).exit(_this);
974
1380
  // Notify the new container that the item has entered.
975
- _this.entered.emit({ item: _this, container: /** @type {?} */ ((newContainer)) });
976
- _this.dropContainer = /** @type {?} */ ((newContainer));
1381
+ _this.entered.next({ item: _this, container: (/** @type {?} */ (newContainer)) });
1382
+ _this.dropContainer = (/** @type {?} */ (newContainer));
977
1383
  _this.dropContainer.enter(_this, x, y);
978
1384
  });
979
1385
  }
980
- this.dropContainer._sortItem(this, x, y, this._pointerDirectionDelta);
1386
+ (/** @type {?} */ (this.dropContainer))._sortItem(this, x, y, this._pointerDirectionDelta);
981
1387
  this._preview.style.transform =
982
1388
  getTransform(x - this._pickupPositionInElement.x, y - this._pickupPositionInElement.y);
983
1389
  };
984
1390
  /**
985
1391
  * Creates the element that will be rendered next to the user's pointer
986
1392
  * and will be used as a preview of the element that is being dragged.
1393
+ */
1394
+ /**
1395
+ * Creates the element that will be rendered next to the user's pointer
1396
+ * and will be used as a preview of the element that is being dragged.
1397
+ * @private
987
1398
  * @return {?}
988
1399
  */
989
- CdkDrag.prototype._createPreviewElement = /**
1400
+ DragRef.prototype._createPreviewElement = /**
990
1401
  * Creates the element that will be rendered next to the user's pointer
991
1402
  * and will be used as a preview of the element that is being dragged.
1403
+ * @private
992
1404
  * @return {?}
993
1405
  */
994
1406
  function () {
@@ -1013,21 +1425,82 @@ var CdkDrag = /** @class */ (function () {
1013
1425
  preview.style.transform = getTransform(elementRect.left, elementRect.top);
1014
1426
  }
1015
1427
  extendStyles(preview.style, {
1428
+ // It's important that we disable the pointer events on the preview, because
1429
+ // it can throw off the `document.elementFromPoint` calls in the `CdkDropList`.
1430
+ pointerEvents: 'none',
1016
1431
  position: 'fixed',
1017
1432
  top: '0',
1018
1433
  left: '0',
1019
1434
  zIndex: '1000'
1020
1435
  });
1436
+ toggleNativeDragInteractions(preview, false);
1021
1437
  preview.classList.add('cdk-drag-preview');
1022
1438
  preview.setAttribute('dir', this._dir ? this._dir.value : 'ltr');
1023
1439
  return preview;
1024
1440
  };
1441
+ /**
1442
+ * Animates the preview element from its current position to the location of the drop placeholder.
1443
+ * @returns Promise that resolves when the animation completes.
1444
+ */
1445
+ /**
1446
+ * Animates the preview element from its current position to the location of the drop placeholder.
1447
+ * @private
1448
+ * @return {?} Promise that resolves when the animation completes.
1449
+ */
1450
+ DragRef.prototype._animatePreviewToPlaceholder = /**
1451
+ * Animates the preview element from its current position to the location of the drop placeholder.
1452
+ * @private
1453
+ * @return {?} Promise that resolves when the animation completes.
1454
+ */
1455
+ function () {
1456
+ var _this = this;
1457
+ // If the user hasn't moved yet, the transitionend event won't fire.
1458
+ if (!this._hasMoved) {
1459
+ return Promise.resolve();
1460
+ }
1461
+ /** @type {?} */
1462
+ var placeholderRect = this._placeholder.getBoundingClientRect();
1463
+ // Apply the class that adds a transition to the preview.
1464
+ this._preview.classList.add('cdk-drag-animating');
1465
+ // Move the preview to the placeholder position.
1466
+ this._preview.style.transform = getTransform(placeholderRect.left, placeholderRect.top);
1467
+ // If the element doesn't have a `transition`, the `transitionend` event won't fire. Since
1468
+ // we need to trigger a style recalculation in order for the `cdk-drag-animating` class to
1469
+ // apply its style, we take advantage of the available info to figure out whether we need to
1470
+ // bind the event in the first place.
1471
+ /** @type {?} */
1472
+ var duration = getTransformTransitionDurationInMs(this._preview);
1473
+ if (duration === 0) {
1474
+ return Promise.resolve();
1475
+ }
1476
+ return this._ngZone.runOutsideAngular(function () {
1477
+ return new Promise(function (resolve) {
1478
+ /** @type {?} */
1479
+ var handler = (/** @type {?} */ ((function (event) {
1480
+ if (!event || (event.target === _this._preview && event.propertyName === 'transform')) {
1481
+ _this._preview.removeEventListener('transitionend', handler);
1482
+ resolve();
1483
+ clearTimeout(timeout);
1484
+ }
1485
+ })));
1486
+ // If a transition is short enough, the browser might not fire the `transitionend` event.
1487
+ // Since we know how long it's supposed to take, add a timeout with a 50% buffer that'll
1488
+ // fire if the transition hasn't completed when it was supposed to.
1489
+ /** @type {?} */
1490
+ var timeout = setTimeout((/** @type {?} */ (handler)), duration * 1.5);
1491
+ _this._preview.addEventListener('transitionend', handler);
1492
+ });
1493
+ });
1494
+ };
1495
+ /** Creates an element that will be shown instead of the current element while dragging. */
1025
1496
  /**
1026
1497
  * Creates an element that will be shown instead of the current element while dragging.
1498
+ * @private
1027
1499
  * @return {?}
1028
1500
  */
1029
- CdkDrag.prototype._createPlaceholderElement = /**
1501
+ DragRef.prototype._createPlaceholderElement = /**
1030
1502
  * Creates an element that will be shown instead of the current element while dragging.
1503
+ * @private
1031
1504
  * @return {?}
1032
1505
  */
1033
1506
  function () {
@@ -1045,12 +1518,19 @@ var CdkDrag = /** @class */ (function () {
1045
1518
  };
1046
1519
  /**
1047
1520
  * Figures out the coordinates at which an element was picked up.
1521
+ * @param referenceElement Element that initiated the dragging.
1522
+ * @param event Event that initiated the dragging.
1523
+ */
1524
+ /**
1525
+ * Figures out the coordinates at which an element was picked up.
1526
+ * @private
1048
1527
  * @param {?} referenceElement Element that initiated the dragging.
1049
1528
  * @param {?} event Event that initiated the dragging.
1050
1529
  * @return {?}
1051
1530
  */
1052
- CdkDrag.prototype._getPointerPositionInElement = /**
1531
+ DragRef.prototype._getPointerPositionInElement = /**
1053
1532
  * Figures out the coordinates at which an element was picked up.
1533
+ * @private
1054
1534
  * @param {?} referenceElement Element that initiated the dragging.
1055
1535
  * @param {?} event Event that initiated the dragging.
1056
1536
  * @return {?}
@@ -1063,7 +1543,7 @@ var CdkDrag = /** @class */ (function () {
1063
1543
  /** @type {?} */
1064
1544
  var referenceRect = handleElement ? handleElement.getBoundingClientRect() : elementRect;
1065
1545
  /** @type {?} */
1066
- var point = this._isTouchEvent(event) ? event.targetTouches[0] : event;
1546
+ var point = isTouchEvent(event) ? event.targetTouches[0] : event;
1067
1547
  /** @type {?} */
1068
1548
  var x = point.pageX - referenceRect.left - this._scrollPosition.left;
1069
1549
  /** @type {?} */
@@ -1073,87 +1553,38 @@ var CdkDrag = /** @class */ (function () {
1073
1553
  y: referenceRect.top - elementRect.top + y
1074
1554
  };
1075
1555
  };
1076
- /**
1077
- * Animates the preview element from its current position to the location of the drop placeholder.
1078
- * @return {?} Promise that resolves when the animation completes.
1079
- */
1080
- CdkDrag.prototype._animatePreviewToPlaceholder = /**
1081
- * Animates the preview element from its current position to the location of the drop placeholder.
1082
- * @return {?} Promise that resolves when the animation completes.
1083
- */
1084
- function () {
1085
- var _this = this;
1086
- // If the user hasn't moved yet, the transitionend event won't fire.
1087
- if (!this._hasMoved) {
1088
- return Promise.resolve();
1089
- }
1090
- /** @type {?} */
1091
- var placeholderRect = this._placeholder.getBoundingClientRect();
1092
- // Apply the class that adds a transition to the preview.
1093
- this._preview.classList.add('cdk-drag-animating');
1094
- // Move the preview to the placeholder position.
1095
- this._preview.style.transform = getTransform(placeholderRect.left, placeholderRect.top);
1096
- /** @type {?} */
1097
- var duration = getTransformTransitionDurationInMs(this._preview);
1098
- if (duration === 0) {
1099
- return Promise.resolve();
1100
- }
1101
- return this._ngZone.runOutsideAngular(function () {
1102
- return new Promise(function (resolve) {
1103
- /** @type {?} */
1104
- var handler = /** @type {?} */ ((function (event) {
1105
- if (!event || (event.target === _this._preview && event.propertyName === 'transform')) {
1106
- _this._preview.removeEventListener('transitionend', handler);
1107
- resolve();
1108
- clearTimeout(timeout);
1109
- }
1110
- }));
1111
- /** @type {?} */
1112
- var timeout = setTimeout(/** @type {?} */ (handler), duration * 1.5);
1113
- _this._preview.addEventListener('transitionend', handler);
1114
- });
1115
- });
1116
- };
1117
- /**
1118
- * Helper to remove an element from the DOM and to do all the necessary null checks.
1119
- * @param {?} element Element to be removed.
1120
- * @return {?}
1121
- */
1122
- CdkDrag.prototype._removeElement = /**
1123
- * Helper to remove an element from the DOM and to do all the necessary null checks.
1124
- * @param {?} element Element to be removed.
1125
- * @return {?}
1126
- */
1127
- function (element) {
1128
- if (element && element.parentNode) {
1129
- element.parentNode.removeChild(element);
1130
- }
1131
- };
1556
+ /** Determines the point of the page that was touched by the user. */
1132
1557
  /**
1133
1558
  * Determines the point of the page that was touched by the user.
1559
+ * @private
1134
1560
  * @param {?} event
1135
1561
  * @return {?}
1136
1562
  */
1137
- CdkDrag.prototype._getPointerPositionOnPage = /**
1563
+ DragRef.prototype._getPointerPositionOnPage = /**
1138
1564
  * Determines the point of the page that was touched by the user.
1565
+ * @private
1139
1566
  * @param {?} event
1140
1567
  * @return {?}
1141
1568
  */
1142
1569
  function (event) {
1570
+ // `touches` will be empty for start/end events so we have to fall back to `changedTouches`.
1143
1571
  /** @type {?} */
1144
- var point = this._isTouchEvent(event) ? event.touches[0] : event;
1572
+ var point = isTouchEvent(event) ? (event.touches[0] || event.changedTouches[0]) : event;
1145
1573
  return {
1146
1574
  x: point.pageX - this._scrollPosition.left,
1147
1575
  y: point.pageY - this._scrollPosition.top
1148
1576
  };
1149
1577
  };
1578
+ /** Gets the pointer position on the page, accounting for any position constraints. */
1150
1579
  /**
1151
1580
  * Gets the pointer position on the page, accounting for any position constraints.
1581
+ * @private
1152
1582
  * @param {?} event
1153
1583
  * @return {?}
1154
1584
  */
1155
- CdkDrag.prototype._getConstrainedPointerPosition = /**
1585
+ DragRef.prototype._getConstrainedPointerPosition = /**
1156
1586
  * Gets the pointer position on the page, accounting for any position constraints.
1587
+ * @private
1157
1588
  * @param {?} event
1158
1589
  * @return {?}
1159
1590
  */
@@ -1168,63 +1599,36 @@ var CdkDrag = /** @class */ (function () {
1168
1599
  else if (this.lockAxis === 'y' || dropContainerLock === 'y') {
1169
1600
  point.x = this._pickupPositionOnPage.x;
1170
1601
  }
1602
+ if (this._boundaryRect) {
1603
+ var _a = this._pickupPositionInElement, pickupX = _a.x, pickupY = _a.y;
1604
+ /** @type {?} */
1605
+ var boundaryRect = this._boundaryRect;
1606
+ /** @type {?} */
1607
+ var previewRect = (/** @type {?} */ (this._previewRect));
1608
+ /** @type {?} */
1609
+ var minY = boundaryRect.top + pickupY;
1610
+ /** @type {?} */
1611
+ var maxY = boundaryRect.bottom - (previewRect.height - pickupY);
1612
+ /** @type {?} */
1613
+ var minX = boundaryRect.left + pickupX;
1614
+ /** @type {?} */
1615
+ var maxX = boundaryRect.right - (previewRect.width - pickupX);
1616
+ point.x = clamp$1(point.x, minX, maxX);
1617
+ point.y = clamp$1(point.y, minY, maxY);
1618
+ }
1171
1619
  return point;
1172
1620
  };
1621
+ /** Updates the current drag delta, based on the user's current pointer position on the page. */
1173
1622
  /**
1174
- * Determines whether an event is a touch event.
1175
- * @param {?} event
1176
- * @return {?}
1177
- */
1178
- CdkDrag.prototype._isTouchEvent = /**
1179
- * Determines whether an event is a touch event.
1180
- * @param {?} event
1181
- * @return {?}
1182
- */
1183
- function (event) {
1184
- return event.type.startsWith('touch');
1185
- };
1186
- /**
1187
- * Destroys the preview element and its ViewRef.
1188
- * @return {?}
1189
- */
1190
- CdkDrag.prototype._destroyPreview = /**
1191
- * Destroys the preview element and its ViewRef.
1623
+ * Updates the current drag delta, based on the user's current pointer position on the page.
1624
+ * @private
1625
+ * @param {?} pointerPositionOnPage
1192
1626
  * @return {?}
1193
1627
  */
1194
- function () {
1195
- if (this._preview) {
1196
- this._removeElement(this._preview);
1197
- }
1198
- if (this._previewRef) {
1199
- this._previewRef.destroy();
1200
- }
1201
- this._preview = this._previewRef = /** @type {?} */ ((null));
1202
- };
1203
- /**
1204
- * Destroys the placeholder element and its ViewRef.
1205
- * @return {?}
1206
- */
1207
- CdkDrag.prototype._destroyPlaceholder = /**
1208
- * Destroys the placeholder element and its ViewRef.
1209
- * @return {?}
1210
- */
1211
- function () {
1212
- if (this._placeholder) {
1213
- this._removeElement(this._placeholder);
1214
- }
1215
- if (this._placeholderRef) {
1216
- this._placeholderRef.destroy();
1217
- }
1218
- this._placeholder = this._placeholderRef = /** @type {?} */ ((null));
1219
- };
1220
- /**
1221
- * Updates the current drag delta, based on the user's current pointer position on the page.
1222
- * @param {?} pointerPositionOnPage
1223
- * @return {?}
1224
- */
1225
- CdkDrag.prototype._updatePointerDirectionDelta = /**
1226
- * Updates the current drag delta, based on the user's current pointer position on the page.
1227
- * @param {?} pointerPositionOnPage
1628
+ DragRef.prototype._updatePointerDirectionDelta = /**
1629
+ * Updates the current drag delta, based on the user's current pointer position on the page.
1630
+ * @private
1631
+ * @param {?} pointerPositionOnPage
1228
1632
  * @return {?}
1229
1633
  */
1230
1634
  function (pointerPositionOnPage) {
@@ -1233,6 +1637,7 @@ var CdkDrag = /** @class */ (function () {
1233
1637
  var delta = this._pointerDirectionDelta;
1234
1638
  /** @type {?} */
1235
1639
  var positionSinceLastChange = this._pointerPositionAtLastDirectionChange;
1640
+ // Amount of pixels the user has dragged since the last time the direction changed.
1236
1641
  /** @type {?} */
1237
1642
  var changeX = Math.abs(x - positionSinceLastChange.x);
1238
1643
  /** @type {?} */
@@ -1251,84 +1656,46 @@ var CdkDrag = /** @class */ (function () {
1251
1656
  }
1252
1657
  return delta;
1253
1658
  };
1659
+ /** Toggles the native drag interactions, based on how many handles are registered. */
1254
1660
  /**
1255
- * Gets the root draggable element, based on the `rootElementSelector`.
1661
+ * Toggles the native drag interactions, based on how many handles are registered.
1662
+ * @private
1256
1663
  * @return {?}
1257
1664
  */
1258
- CdkDrag.prototype._getRootElement = /**
1259
- * Gets the root draggable element, based on the `rootElementSelector`.
1665
+ DragRef.prototype._toggleNativeDragInteractions = /**
1666
+ * Toggles the native drag interactions, based on how many handles are registered.
1667
+ * @private
1260
1668
  * @return {?}
1261
1669
  */
1262
1670
  function () {
1263
- if (this.rootElementSelector) {
1264
- /** @type {?} */
1265
- var selector = this.rootElementSelector;
1266
- /** @type {?} */
1267
- var currentElement = /** @type {?} */ (this.element.nativeElement.parentElement);
1268
- while (currentElement) {
1269
- // IE doesn't support `matches` so we have to fall back to `msMatchesSelector`.
1270
- if (currentElement.matches ? currentElement.matches(selector) :
1271
- (/** @type {?} */ (currentElement)).msMatchesSelector(selector)) {
1272
- return currentElement;
1273
- }
1274
- currentElement = currentElement.parentElement;
1275
- }
1671
+ if (!this._rootElement || !this._handles) {
1672
+ return;
1673
+ }
1674
+ /** @type {?} */
1675
+ var shouldEnable = this.disabled || this._handles.length > 0;
1676
+ if (shouldEnable !== this._nativeInteractionsEnabled) {
1677
+ this._nativeInteractionsEnabled = shouldEnable;
1678
+ toggleNativeDragInteractions(this._rootElement, shouldEnable);
1276
1679
  }
1277
- return this.element.nativeElement;
1278
1680
  };
1681
+ /** Removes the manually-added event listeners from the root element. */
1279
1682
  /**
1280
- * Unsubscribes from the global subscriptions.
1683
+ * Removes the manually-added event listeners from the root element.
1684
+ * @private
1685
+ * @param {?} element
1281
1686
  * @return {?}
1282
1687
  */
1283
- CdkDrag.prototype._removeSubscriptions = /**
1284
- * Unsubscribes from the global subscriptions.
1688
+ DragRef.prototype._removeRootElementListeners = /**
1689
+ * Removes the manually-added event listeners from the root element.
1690
+ * @private
1691
+ * @param {?} element
1285
1692
  * @return {?}
1286
1693
  */
1287
- function () {
1288
- this._pointerMoveSubscription.unsubscribe();
1289
- this._pointerUpSubscription.unsubscribe();
1290
- };
1291
- CdkDrag.decorators = [
1292
- { type: Directive, args: [{
1293
- selector: '[cdkDrag]',
1294
- exportAs: 'cdkDrag',
1295
- host: {
1296
- 'class': 'cdk-drag',
1297
- '[class.cdk-drag-dragging]': '_hasStartedDragging && _isDragging()',
1298
- },
1299
- providers: [{
1300
- provide: CDK_DRAG_PARENT,
1301
- useExisting: CdkDrag
1302
- }]
1303
- },] },
1304
- ];
1305
- /** @nocollapse */
1306
- CdkDrag.ctorParameters = function () { return [
1307
- { type: ElementRef },
1308
- { type: undefined, decorators: [{ type: Inject, args: [CDK_DROP_LIST_CONTAINER,] }, { type: Optional }, { type: SkipSelf }] },
1309
- { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] },
1310
- { type: NgZone },
1311
- { type: ViewContainerRef },
1312
- { type: ViewportRuler },
1313
- { type: DragDropRegistry },
1314
- { type: undefined, decorators: [{ type: Inject, args: [CDK_DRAG_CONFIG,] }] },
1315
- { type: Directionality, decorators: [{ type: Optional }] }
1316
- ]; };
1317
- CdkDrag.propDecorators = {
1318
- _handles: [{ type: ContentChildren, args: [CdkDragHandle, { descendants: true },] }],
1319
- _previewTemplate: [{ type: ContentChild, args: [CdkDragPreview,] }],
1320
- _placeholderTemplate: [{ type: ContentChild, args: [CdkDragPlaceholder,] }],
1321
- data: [{ type: Input, args: ['cdkDragData',] }],
1322
- lockAxis: [{ type: Input, args: ['cdkDragLockAxis',] }],
1323
- rootElementSelector: [{ type: Input, args: ['cdkDragRootElement',] }],
1324
- started: [{ type: Output, args: ['cdkDragStarted',] }],
1325
- ended: [{ type: Output, args: ['cdkDragEnded',] }],
1326
- entered: [{ type: Output, args: ['cdkDragEntered',] }],
1327
- exited: [{ type: Output, args: ['cdkDragExited',] }],
1328
- dropped: [{ type: Output, args: ['cdkDragDropped',] }],
1329
- moved: [{ type: Output, args: ['cdkDragMoved',] }]
1694
+ function (element) {
1695
+ element.removeEventListener('mousedown', this._pointerDown, activeEventListenerOptions);
1696
+ element.removeEventListener('touchstart', this._pointerDown, passiveEventListenerOptions);
1330
1697
  };
1331
- return CdkDrag;
1698
+ return DragRef;
1332
1699
  }());
1333
1700
  /**
1334
1701
  * Gets a 3d `transform` that can be applied to an element.
@@ -1337,7 +1704,9 @@ var CdkDrag = /** @class */ (function () {
1337
1704
  * @return {?}
1338
1705
  */
1339
1706
  function getTransform(x, y) {
1340
- return "translate3d(" + x + "px, " + y + "px, 0)";
1707
+ // Round the transforms since some browsers will
1708
+ // blur the elements for sub-pixel transforms.
1709
+ return "translate3d(" + Math.round(x) + "px, " + Math.round(y) + "px, 0)";
1341
1710
  }
1342
1711
  /**
1343
1712
  * Creates a deep clone of an element.
@@ -1346,220 +1715,1396 @@ function getTransform(x, y) {
1346
1715
  */
1347
1716
  function deepCloneNode(node) {
1348
1717
  /** @type {?} */
1349
- var clone = /** @type {?} */ (node.cloneNode(true));
1718
+ var clone = (/** @type {?} */ (node.cloneNode(true)));
1350
1719
  // Remove the `id` to avoid having multiple elements with the same id on the page.
1351
1720
  clone.removeAttribute('id');
1352
1721
  return clone;
1353
1722
  }
1354
-
1355
- /**
1356
- * @fileoverview added by tsickle
1357
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
1358
- */
1359
-
1360
- /**
1361
- * Moves an item one index in an array to another.
1362
- * @template T
1363
- * @param {?} array Array in which to move the item.
1364
- * @param {?} fromIndex Starting index of the item.
1365
- * @param {?} toIndex Index to which the item should be moved.
1366
- * @return {?}
1367
- */
1368
- function moveItemInArray(array, fromIndex, toIndex) {
1369
- /** @type {?} */
1370
- var from = clamp(fromIndex, array.length - 1);
1371
- /** @type {?} */
1372
- var to = clamp(toIndex, array.length - 1);
1373
- if (from === to) {
1374
- return;
1375
- }
1376
- /** @type {?} */
1377
- var target = array[from];
1378
- /** @type {?} */
1379
- var delta = to < from ? -1 : 1;
1380
- for (var i = from; i !== to; i += delta) {
1381
- array[i] = array[i + delta];
1382
- }
1383
- array[to] = target;
1384
- }
1385
1723
  /**
1386
- * Moves an item from one array to another.
1387
- * @template T
1388
- * @param {?} currentArray Array from which to transfer the item.
1389
- * @param {?} targetArray Array into which to put the item.
1390
- * @param {?} currentIndex Index of the item in its current array.
1391
- * @param {?} targetIndex Index at which to insert the item.
1724
+ * Clamps a value between a minimum and a maximum.
1725
+ * @param {?} value
1726
+ * @param {?} min
1727
+ * @param {?} max
1392
1728
  * @return {?}
1393
1729
  */
1394
- function transferArrayItem(currentArray, targetArray, currentIndex, targetIndex) {
1395
- /** @type {?} */
1396
- var from = clamp(currentIndex, currentArray.length - 1);
1397
- /** @type {?} */
1398
- var to = clamp(targetIndex, targetArray.length);
1399
- if (currentArray.length) {
1400
- targetArray.splice(to, 0, currentArray.splice(from, 1)[0]);
1401
- }
1730
+ function clamp$1(value, min, max) {
1731
+ return Math.max(min, Math.min(max, value));
1402
1732
  }
1403
1733
  /**
1404
- * Copies an item from one array to another, leaving it in its
1405
- * original position in current array.
1406
- * @template T
1407
- * @param {?} currentArray Array from which to copy the item.
1408
- * @param {?} targetArray Array into which is copy the item.
1409
- * @param {?} currentIndex Index of the item in its current array.
1410
- * @param {?} targetIndex Index at which to insert the item.
1411
- *
1734
+ * Helper to remove an element from the DOM and to do all the necessary null checks.
1735
+ * @param {?} element Element to be removed.
1412
1736
  * @return {?}
1413
1737
  */
1414
- function copyArrayItem(currentArray, targetArray, currentIndex, targetIndex) {
1415
- /** @type {?} */
1416
- var to = clamp(targetIndex, targetArray.length);
1417
- if (currentArray.length) {
1418
- targetArray.splice(to, 0, currentArray[currentIndex]);
1738
+ function removeElement(element) {
1739
+ if (element && element.parentNode) {
1740
+ element.parentNode.removeChild(element);
1419
1741
  }
1420
1742
  }
1421
1743
  /**
1422
- * Clamps a number between zero and a maximum.
1423
- * @param {?} value
1424
- * @param {?} max
1744
+ * Determines whether an event is a touch event.
1745
+ * @param {?} event
1425
1746
  * @return {?}
1426
1747
  */
1427
- function clamp(value, max) {
1428
- return Math.max(0, Math.min(max, value));
1748
+ function isTouchEvent(event) {
1749
+ return event.type.startsWith('touch');
1429
1750
  }
1430
1751
 
1431
1752
  /**
1432
1753
  * @fileoverview added by tsickle
1433
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
1754
+ * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1434
1755
  */
1435
1756
  /**
1436
- * Declaratively connects sibling `cdkDropList` instances together. All of the `cdkDropList`
1437
- * elements that are placed inside a `cdkDropListGroup` will be connected to each other
1438
- * automatically. Can be used as an alternative to the `cdkDropListConnectedTo` input
1439
- * from `cdkDropList`.
1440
- * @template T
1757
+ * Injection token that can be used to configure the behavior of `CdkDrag`.
1758
+ * @type {?}
1441
1759
  */
1442
- var CdkDropListGroup = /** @class */ (function () {
1443
- function CdkDropListGroup() {
1444
- /**
1445
- * Drop lists registered inside the group.
1446
- */
1447
- this._items = new Set();
1448
- }
1449
- /**
1450
- * @return {?}
1451
- */
1452
- CdkDropListGroup.prototype.ngOnDestroy = /**
1453
- * @return {?}
1454
- */
1455
- function () {
1456
- this._items.clear();
1457
- };
1458
- CdkDropListGroup.decorators = [
1459
- { type: Directive, args: [{
1460
- selector: '[cdkDropListGroup]'
1461
- },] },
1462
- ];
1463
- return CdkDropListGroup;
1464
- }());
1465
-
1760
+ var CDK_DRAG_CONFIG = new InjectionToken('CDK_DRAG_CONFIG', {
1761
+ providedIn: 'root',
1762
+ factory: CDK_DRAG_CONFIG_FACTORY
1763
+ });
1466
1764
  /**
1467
- * @fileoverview added by tsickle
1468
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
1765
+ * \@docs-private
1766
+ * @return {?}
1469
1767
  */
1470
- /** *
1471
- * Counter used to generate unique ids for drop zones.
1472
- @type {?} */
1473
- var _uniqueIdCounter = 0;
1474
- /** *
1475
- * Proximity, as a ratio to width/height, at which a
1476
- * dragged item will affect the drop container.
1477
- @type {?} */
1478
- var DROP_PROXIMITY_THRESHOLD = 0.05;
1768
+ function CDK_DRAG_CONFIG_FACTORY() {
1769
+ return { dragStartThreshold: 5, pointerDirectionChangeThreshold: 5 };
1770
+ }
1479
1771
  /**
1480
- * Container that wraps a set of draggable items.
1772
+ * Element that can be moved inside a CdkDropList container.
1481
1773
  * @template T
1482
1774
  */
1483
- var CdkDropList = /** @class */ (function () {
1484
- function CdkDropList(element, _dragDropRegistry, _changeDetectorRef, _dir, _group) {
1775
+ var CdkDrag = /** @class */ (function () {
1776
+ function CdkDrag(element, dropContainer, _document, _ngZone, _viewContainerRef, _viewportRuler, _dragDropRegistry, _config, _dir) {
1777
+ var _this = this;
1485
1778
  this.element = element;
1779
+ this.dropContainer = dropContainer;
1780
+ this._document = _document;
1781
+ this._ngZone = _ngZone;
1782
+ this._viewContainerRef = _viewContainerRef;
1783
+ this._viewportRuler = _viewportRuler;
1486
1784
  this._dragDropRegistry = _dragDropRegistry;
1487
- this._changeDetectorRef = _changeDetectorRef;
1785
+ this._config = _config;
1488
1786
  this._dir = _dir;
1489
- this._group = _group;
1490
- /**
1491
- * Other draggable containers that this container is connected to and into which the
1492
- * container's items can be transferred. Can either be references to other drop containers,
1493
- * or their unique IDs.
1494
- */
1495
- this.connectedTo = [];
1496
1787
  /**
1497
- * Direction in which the list is oriented.
1788
+ * Subscription to the stream that initializes the root element.
1498
1789
  */
1499
- this.orientation = 'vertical';
1790
+ this._rootElementInitSubscription = Subscription.EMPTY;
1791
+ this._disabled = false;
1500
1792
  /**
1501
- * Unique ID for the drop zone. Can be used as a reference
1502
- * in the `connectedTo` of another `CdkDropList`.
1793
+ * Emits when the user starts dragging the item.
1503
1794
  */
1504
- this.id = "cdk-drop-list-" + _uniqueIdCounter++;
1795
+ this.started = new EventEmitter();
1505
1796
  /**
1506
- * Function that is used to determine whether an item
1507
- * is allowed to be moved into a drop container.
1797
+ * Emits when the user has released a drag item, before any animations have started.
1508
1798
  */
1509
- this.enterPredicate = function () { return true; };
1799
+ this.released = new EventEmitter();
1510
1800
  /**
1511
- * Emits when the user drops an item inside the container.
1801
+ * Emits when the user stops dragging an item in the container.
1512
1802
  */
1513
- this.dropped = new EventEmitter();
1803
+ this.ended = new EventEmitter();
1514
1804
  /**
1515
- * Emits when the user has moved a new drag item into this container.
1805
+ * Emits when the user has moved the item into a new container.
1516
1806
  */
1517
1807
  this.entered = new EventEmitter();
1518
1808
  /**
1519
- * Emits when the user removes an item from the container
1520
- * by dragging it into another container.
1809
+ * Emits when the user removes the item its container by dragging it into another container.
1521
1810
  */
1522
1811
  this.exited = new EventEmitter();
1523
1812
  /**
1524
- * Emits as the user is swapping items while actively dragging.
1813
+ * Emits when the user drops the item inside a container.
1525
1814
  */
1526
- this.sorted = new EventEmitter();
1815
+ this.dropped = new EventEmitter();
1527
1816
  /**
1528
- * Whether an item in the container is being dragged.
1817
+ * Emits as the user is dragging the item. Use with caution,
1818
+ * because this event will fire for every pixel that the user has dragged.
1529
1819
  */
1530
- this._dragging = false;
1531
- /**
1532
- * Cache of the dimensions of all the items and the sibling containers.
1820
+ this.moved = Observable.create(function (observer) {
1821
+ /** @type {?} */
1822
+ var subscription = _this._dragRef.moved.pipe(map(function (movedEvent) { return ({
1823
+ source: _this,
1824
+ pointerPosition: movedEvent.pointerPosition,
1825
+ event: movedEvent.event,
1826
+ delta: movedEvent.delta
1827
+ }); })).subscribe(observer);
1828
+ return function () {
1829
+ subscription.unsubscribe();
1830
+ };
1831
+ });
1832
+ /** @type {?} */
1833
+ var ref = this._dragRef = new DragRef(element, this._document, this._ngZone, this._viewContainerRef, this._viewportRuler, this._dragDropRegistry, this._config, this.dropContainer ? this.dropContainer._dropListRef : undefined, this._dir);
1834
+ ref.data = this;
1835
+ ref.beforeStarted.subscribe(function () {
1836
+ if (!ref.isDragging()) {
1837
+ ref.disabled = _this.disabled;
1838
+ ref.lockAxis = _this.lockAxis;
1839
+ ref
1840
+ .withBoundaryElement(_this._getBoundaryElement())
1841
+ .withPlaceholderTemplate(_this._placeholderTemplate)
1842
+ .withPreviewTemplate(_this._previewTemplate);
1843
+ }
1844
+ });
1845
+ this._proxyEvents(ref);
1846
+ }
1847
+ Object.defineProperty(CdkDrag.prototype, "disabled", {
1848
+ /** Whether starting to drag this element is disabled. */
1849
+ get: /**
1850
+ * Whether starting to drag this element is disabled.
1851
+ * @return {?}
1533
1852
  */
1534
- this._positionCache = { items: [], siblings: [], self: /** @type {?} */ ({}) };
1535
- /**
1536
- * Keeps track of the item that was last swapped with the dragged item, as
1537
- * well as what direction the pointer was moving in when the swap occured.
1853
+ function () {
1854
+ return this._disabled || (this.dropContainer && this.dropContainer.disabled);
1855
+ },
1856
+ set: /**
1857
+ * @param {?} value
1858
+ * @return {?}
1538
1859
  */
1539
- this._previousSwap = { drag: /** @type {?} */ (null), delta: 0 };
1540
- }
1860
+ function (value) {
1861
+ this._disabled = coerceBooleanProperty(value);
1862
+ this._dragRef.disabled = this._disabled;
1863
+ },
1864
+ enumerable: true,
1865
+ configurable: true
1866
+ });
1867
+ /**
1868
+ * Returns the element that is being used as a placeholder
1869
+ * while the current element is being dragged.
1870
+ */
1541
1871
  /**
1872
+ * Returns the element that is being used as a placeholder
1873
+ * while the current element is being dragged.
1542
1874
  * @return {?}
1543
1875
  */
1544
- CdkDropList.prototype.ngOnInit = /**
1876
+ CdkDrag.prototype.getPlaceholderElement = /**
1877
+ * Returns the element that is being used as a placeholder
1878
+ * while the current element is being dragged.
1545
1879
  * @return {?}
1546
1880
  */
1547
1881
  function () {
1548
- this._dragDropRegistry.registerDropContainer(this);
1549
- if (this._group) {
1550
- this._group._items.add(this);
1551
- }
1882
+ return this._dragRef.getPlaceholderElement();
1552
1883
  };
1884
+ /** Returns the root draggable element. */
1553
1885
  /**
1886
+ * Returns the root draggable element.
1554
1887
  * @return {?}
1555
1888
  */
1556
- CdkDropList.prototype.ngOnDestroy = /**
1889
+ CdkDrag.prototype.getRootElement = /**
1890
+ * Returns the root draggable element.
1557
1891
  * @return {?}
1558
1892
  */
1559
1893
  function () {
1560
- this._dragDropRegistry.removeDropContainer(this);
1561
- if (this._group) {
1562
- this._group._items.delete(this);
1894
+ return this._dragRef.getRootElement();
1895
+ };
1896
+ /** Resets a standalone drag item to its initial position. */
1897
+ /**
1898
+ * Resets a standalone drag item to its initial position.
1899
+ * @return {?}
1900
+ */
1901
+ CdkDrag.prototype.reset = /**
1902
+ * Resets a standalone drag item to its initial position.
1903
+ * @return {?}
1904
+ */
1905
+ function () {
1906
+ this._dragRef.reset();
1907
+ };
1908
+ /**
1909
+ * @return {?}
1910
+ */
1911
+ CdkDrag.prototype.ngAfterViewInit = /**
1912
+ * @return {?}
1913
+ */
1914
+ function () {
1915
+ var _this = this;
1916
+ // We need to wait for the zone to stabilize, in order for the reference
1917
+ // element to be in the proper place in the DOM. This is mostly relevant
1918
+ // for draggable elements inside portals since they get stamped out in
1919
+ // their original DOM position and then they get transferred to the portal.
1920
+ this._rootElementInitSubscription = this._ngZone.onStable.asObservable()
1921
+ .pipe(take(1))
1922
+ .subscribe(function () {
1923
+ _this._updateRootElement();
1924
+ _this._handles.changes
1925
+ .pipe(startWith(_this._handles))
1926
+ .subscribe(function (handleList) {
1927
+ _this._dragRef.withHandles(handleList.filter(function (handle) { return handle._parentDrag === _this; }));
1928
+ });
1929
+ });
1930
+ };
1931
+ /**
1932
+ * @param {?} changes
1933
+ * @return {?}
1934
+ */
1935
+ CdkDrag.prototype.ngOnChanges = /**
1936
+ * @param {?} changes
1937
+ * @return {?}
1938
+ */
1939
+ function (changes) {
1940
+ /** @type {?} */
1941
+ var rootSelectorChange = changes.rootElementSelector;
1942
+ // We don't have to react to the first change since it's being
1943
+ // handled in `ngAfterViewInit` where it needs to be deferred.
1944
+ if (rootSelectorChange && !rootSelectorChange.firstChange) {
1945
+ this._updateRootElement();
1946
+ }
1947
+ };
1948
+ /**
1949
+ * @return {?}
1950
+ */
1951
+ CdkDrag.prototype.ngOnDestroy = /**
1952
+ * @return {?}
1953
+ */
1954
+ function () {
1955
+ this._rootElementInitSubscription.unsubscribe();
1956
+ this._dragRef.dispose();
1957
+ };
1958
+ /** Syncs the root element with the `DragRef`. */
1959
+ /**
1960
+ * Syncs the root element with the `DragRef`.
1961
+ * @private
1962
+ * @return {?}
1963
+ */
1964
+ CdkDrag.prototype._updateRootElement = /**
1965
+ * Syncs the root element with the `DragRef`.
1966
+ * @private
1967
+ * @return {?}
1968
+ */
1969
+ function () {
1970
+ /** @type {?} */
1971
+ var element = this.element.nativeElement;
1972
+ /** @type {?} */
1973
+ var rootElement = this.rootElementSelector ?
1974
+ getClosestMatchingAncestor(element, this.rootElementSelector) : element;
1975
+ if (rootElement && rootElement.nodeType !== this._document.ELEMENT_NODE) {
1976
+ throw Error("cdkDrag must be attached to an element node. " +
1977
+ ("Currently attached to \"" + rootElement.nodeName + "\"."));
1978
+ }
1979
+ this._dragRef.withRootElement(rootElement || element);
1980
+ };
1981
+ /** Gets the boundary element, based on the `boundaryElementSelector`. */
1982
+ /**
1983
+ * Gets the boundary element, based on the `boundaryElementSelector`.
1984
+ * @private
1985
+ * @return {?}
1986
+ */
1987
+ CdkDrag.prototype._getBoundaryElement = /**
1988
+ * Gets the boundary element, based on the `boundaryElementSelector`.
1989
+ * @private
1990
+ * @return {?}
1991
+ */
1992
+ function () {
1993
+ /** @type {?} */
1994
+ var selector = this.boundaryElementSelector;
1995
+ return selector ? getClosestMatchingAncestor(this.element.nativeElement, selector) : null;
1996
+ };
1997
+ /**
1998
+ * Proxies the events from a DragRef to events that
1999
+ * match the interfaces of the CdkDrag outputs.
2000
+ */
2001
+ /**
2002
+ * Proxies the events from a DragRef to events that
2003
+ * match the interfaces of the CdkDrag outputs.
2004
+ * @private
2005
+ * @param {?} ref
2006
+ * @return {?}
2007
+ */
2008
+ CdkDrag.prototype._proxyEvents = /**
2009
+ * Proxies the events from a DragRef to events that
2010
+ * match the interfaces of the CdkDrag outputs.
2011
+ * @private
2012
+ * @param {?} ref
2013
+ * @return {?}
2014
+ */
2015
+ function (ref) {
2016
+ var _this = this;
2017
+ ref.started.subscribe(function () {
2018
+ _this.started.emit({ source: _this });
2019
+ });
2020
+ ref.released.subscribe(function () {
2021
+ _this.released.emit({ source: _this });
2022
+ });
2023
+ ref.ended.subscribe(function () {
2024
+ _this.ended.emit({ source: _this });
2025
+ });
2026
+ ref.entered.subscribe(function (event) {
2027
+ _this.entered.emit({
2028
+ container: event.container.data,
2029
+ item: _this
2030
+ });
2031
+ });
2032
+ ref.exited.subscribe(function (event) {
2033
+ _this.exited.emit({
2034
+ container: event.container.data,
2035
+ item: _this
2036
+ });
2037
+ });
2038
+ ref.dropped.subscribe(function (event) {
2039
+ _this.dropped.emit({
2040
+ previousIndex: event.previousIndex,
2041
+ currentIndex: event.currentIndex,
2042
+ previousContainer: event.previousContainer.data,
2043
+ container: event.container.data,
2044
+ isPointerOverContainer: event.isPointerOverContainer,
2045
+ item: _this
2046
+ });
2047
+ });
2048
+ };
2049
+ CdkDrag.decorators = [
2050
+ { type: Directive, args: [{
2051
+ selector: '[cdkDrag]',
2052
+ exportAs: 'cdkDrag',
2053
+ host: {
2054
+ 'class': 'cdk-drag',
2055
+ '[class.cdk-drag-dragging]': '_dragRef.isDragging()',
2056
+ },
2057
+ providers: [{ provide: CDK_DRAG_PARENT, useExisting: CdkDrag }]
2058
+ },] },
2059
+ ];
2060
+ /** @nocollapse */
2061
+ CdkDrag.ctorParameters = function () { return [
2062
+ { type: ElementRef },
2063
+ { type: undefined, decorators: [{ type: Inject, args: [CDK_DROP_LIST,] }, { type: Optional }, { type: SkipSelf }] },
2064
+ { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] },
2065
+ { type: NgZone },
2066
+ { type: ViewContainerRef },
2067
+ { type: ViewportRuler },
2068
+ { type: DragDropRegistry },
2069
+ { type: undefined, decorators: [{ type: Inject, args: [CDK_DRAG_CONFIG,] }] },
2070
+ { type: Directionality, decorators: [{ type: Optional }] }
2071
+ ]; };
2072
+ CdkDrag.propDecorators = {
2073
+ _handles: [{ type: ContentChildren, args: [CdkDragHandle, { descendants: true },] }],
2074
+ _previewTemplate: [{ type: ContentChild, args: [CdkDragPreview,] }],
2075
+ _placeholderTemplate: [{ type: ContentChild, args: [CdkDragPlaceholder,] }],
2076
+ data: [{ type: Input, args: ['cdkDragData',] }],
2077
+ lockAxis: [{ type: Input, args: ['cdkDragLockAxis',] }],
2078
+ rootElementSelector: [{ type: Input, args: ['cdkDragRootElement',] }],
2079
+ boundaryElementSelector: [{ type: Input, args: ['cdkDragBoundary',] }],
2080
+ disabled: [{ type: Input, args: ['cdkDragDisabled',] }],
2081
+ started: [{ type: Output, args: ['cdkDragStarted',] }],
2082
+ released: [{ type: Output, args: ['cdkDragReleased',] }],
2083
+ ended: [{ type: Output, args: ['cdkDragEnded',] }],
2084
+ entered: [{ type: Output, args: ['cdkDragEntered',] }],
2085
+ exited: [{ type: Output, args: ['cdkDragExited',] }],
2086
+ dropped: [{ type: Output, args: ['cdkDragDropped',] }],
2087
+ moved: [{ type: Output, args: ['cdkDragMoved',] }]
2088
+ };
2089
+ return CdkDrag;
2090
+ }());
2091
+ /**
2092
+ * Gets the closest ancestor of an element that matches a selector.
2093
+ * @param {?} element
2094
+ * @param {?} selector
2095
+ * @return {?}
2096
+ */
2097
+ function getClosestMatchingAncestor(element, selector) {
2098
+ /** @type {?} */
2099
+ var currentElement = (/** @type {?} */ (element.parentElement));
2100
+ while (currentElement) {
2101
+ // IE doesn't support `matches` so we have to fall back to `msMatchesSelector`.
2102
+ if (currentElement.matches ? currentElement.matches(selector) :
2103
+ ((/** @type {?} */ (currentElement))).msMatchesSelector(selector)) {
2104
+ return currentElement;
2105
+ }
2106
+ currentElement = currentElement.parentElement;
2107
+ }
2108
+ return null;
2109
+ }
2110
+
2111
+ /**
2112
+ * @fileoverview added by tsickle
2113
+ * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2114
+ */
2115
+ /**
2116
+ * Declaratively connects sibling `cdkDropList` instances together. All of the `cdkDropList`
2117
+ * elements that are placed inside a `cdkDropListGroup` will be connected to each other
2118
+ * automatically. Can be used as an alternative to the `cdkDropListConnectedTo` input
2119
+ * from `cdkDropList`.
2120
+ * @template T
2121
+ */
2122
+ var CdkDropListGroup = /** @class */ (function () {
2123
+ function CdkDropListGroup() {
2124
+ /**
2125
+ * Drop lists registered inside the group.
2126
+ */
2127
+ this._items = new Set();
2128
+ this._disabled = false;
2129
+ }
2130
+ Object.defineProperty(CdkDropListGroup.prototype, "disabled", {
2131
+ /** Whether starting a dragging sequence from inside this group is disabled. */
2132
+ get: /**
2133
+ * Whether starting a dragging sequence from inside this group is disabled.
2134
+ * @return {?}
2135
+ */
2136
+ function () { return this._disabled; },
2137
+ set: /**
2138
+ * @param {?} value
2139
+ * @return {?}
2140
+ */
2141
+ function (value) {
2142
+ this._disabled = coerceBooleanProperty(value);
2143
+ },
2144
+ enumerable: true,
2145
+ configurable: true
2146
+ });
2147
+ /**
2148
+ * @return {?}
2149
+ */
2150
+ CdkDropListGroup.prototype.ngOnDestroy = /**
2151
+ * @return {?}
2152
+ */
2153
+ function () {
2154
+ this._items.clear();
2155
+ };
2156
+ CdkDropListGroup.decorators = [
2157
+ { type: Directive, args: [{
2158
+ selector: '[cdkDropListGroup]',
2159
+ exportAs: 'cdkDropListGroup',
2160
+ },] },
2161
+ ];
2162
+ CdkDropListGroup.propDecorators = {
2163
+ disabled: [{ type: Input, args: ['cdkDropListGroupDisabled',] }]
2164
+ };
2165
+ return CdkDropListGroup;
2166
+ }());
2167
+
2168
+ /**
2169
+ * @fileoverview added by tsickle
2170
+ * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2171
+ */
2172
+ /**
2173
+ * Counter used to generate unique ids for drop refs.
2174
+ * @type {?}
2175
+ */
2176
+ var _uniqueIdCounter = 0;
2177
+ /**
2178
+ * Proximity, as a ratio to width/height, at which a
2179
+ * dragged item will affect the drop container.
2180
+ * @type {?}
2181
+ */
2182
+ var DROP_PROXIMITY_THRESHOLD = 0.05;
2183
+ /**
2184
+ * Reference to a drop list. Used to manipulate or dispose of the container.
2185
+ * \@docs-private
2186
+ * @template T
2187
+ */
2188
+ var /**
2189
+ * Reference to a drop list. Used to manipulate or dispose of the container.
2190
+ * \@docs-private
2191
+ * @template T
2192
+ */
2193
+ DropListRef = /** @class */ (function () {
2194
+ function DropListRef(element, _dragDropRegistry, _document, _dir) {
2195
+ this.element = element;
2196
+ this._dragDropRegistry = _dragDropRegistry;
2197
+ this._dir = _dir;
2198
+ /**
2199
+ * Unique ID for the drop list.
2200
+ * @deprecated No longer being used. To be removed.
2201
+ * \@breaking-change 8.0.0
2202
+ */
2203
+ this.id = "cdk-drop-list-ref-" + _uniqueIdCounter++;
2204
+ /**
2205
+ * Whether starting a dragging sequence from this container is disabled.
2206
+ */
2207
+ this.disabled = false;
2208
+ /**
2209
+ * Function that is used to determine whether an item
2210
+ * is allowed to be moved into a drop container.
2211
+ */
2212
+ this.enterPredicate = function () { return true; };
2213
+ /**
2214
+ * Emits right before dragging has started.
2215
+ */
2216
+ this.beforeStarted = new Subject();
2217
+ /**
2218
+ * Emits when the user has moved a new drag item into this container.
2219
+ */
2220
+ this.entered = new Subject();
2221
+ /**
2222
+ * Emits when the user removes an item from the container
2223
+ * by dragging it into another container.
2224
+ */
2225
+ this.exited = new Subject();
2226
+ /**
2227
+ * Emits when the user drops an item inside the container.
2228
+ */
2229
+ this.dropped = new Subject();
2230
+ /**
2231
+ * Emits as the user is swapping items while actively dragging.
2232
+ */
2233
+ this.sorted = new Subject();
2234
+ /**
2235
+ * Whether an item in the list is being dragged.
2236
+ */
2237
+ this._isDragging = false;
2238
+ /**
2239
+ * Cache of the dimensions of all the items and the sibling containers.
2240
+ */
2241
+ this._positionCache = { items: [], siblings: [], self: (/** @type {?} */ ({})) };
2242
+ /**
2243
+ * Keeps track of the item that was last swapped with the dragged item, as
2244
+ * well as what direction the pointer was moving in when the swap occured.
2245
+ */
2246
+ this._previousSwap = { drag: (/** @type {?} */ (null)), delta: 0 };
2247
+ this._siblings = [];
2248
+ /**
2249
+ * Direction in which the list is oriented.
2250
+ */
2251
+ this._orientation = 'vertical';
2252
+ /**
2253
+ * Amount of connected siblings that currently have a dragged item.
2254
+ */
2255
+ this._activeSiblings = 0;
2256
+ _dragDropRegistry.registerDropContainer(this);
2257
+ this._document = _document;
2258
+ }
2259
+ /** Removes the drop list functionality from the DOM element. */
2260
+ /**
2261
+ * Removes the drop list functionality from the DOM element.
2262
+ * @return {?}
2263
+ */
2264
+ DropListRef.prototype.dispose = /**
2265
+ * Removes the drop list functionality from the DOM element.
2266
+ * @return {?}
2267
+ */
2268
+ function () {
2269
+ this.beforeStarted.complete();
2270
+ this.entered.complete();
2271
+ this.exited.complete();
2272
+ this.dropped.complete();
2273
+ this.sorted.complete();
2274
+ this._dragDropRegistry.removeDropContainer(this);
2275
+ };
2276
+ /** Whether an item from this list is currently being dragged. */
2277
+ /**
2278
+ * Whether an item from this list is currently being dragged.
2279
+ * @return {?}
2280
+ */
2281
+ DropListRef.prototype.isDragging = /**
2282
+ * Whether an item from this list is currently being dragged.
2283
+ * @return {?}
2284
+ */
2285
+ function () {
2286
+ return this._isDragging;
2287
+ };
2288
+ /** Starts dragging an item. */
2289
+ /**
2290
+ * Starts dragging an item.
2291
+ * @return {?}
2292
+ */
2293
+ DropListRef.prototype.start = /**
2294
+ * Starts dragging an item.
2295
+ * @return {?}
2296
+ */
2297
+ function () {
2298
+ this.beforeStarted.next();
2299
+ this._isDragging = true;
2300
+ this._activeDraggables = this._draggables.slice();
2301
+ this._cachePositions();
2302
+ this._positionCache.siblings.forEach(function (sibling) { return sibling.drop._toggleIsReceiving(true); });
2303
+ };
2304
+ /**
2305
+ * Emits an event to indicate that the user moved an item into the container.
2306
+ * @param item Item that was moved into the container.
2307
+ * @param pointerX Position of the item along the X axis.
2308
+ * @param pointerY Position of the item along the Y axis.
2309
+ */
2310
+ /**
2311
+ * Emits an event to indicate that the user moved an item into the container.
2312
+ * @param {?} item Item that was moved into the container.
2313
+ * @param {?} pointerX Position of the item along the X axis.
2314
+ * @param {?} pointerY Position of the item along the Y axis.
2315
+ * @return {?}
2316
+ */
2317
+ DropListRef.prototype.enter = /**
2318
+ * Emits an event to indicate that the user moved an item into the container.
2319
+ * @param {?} item Item that was moved into the container.
2320
+ * @param {?} pointerX Position of the item along the X axis.
2321
+ * @param {?} pointerY Position of the item along the Y axis.
2322
+ * @return {?}
2323
+ */
2324
+ function (item, pointerX, pointerY) {
2325
+ this.entered.next({ item: item, container: this });
2326
+ this.start();
2327
+ // We use the coordinates of where the item entered the drop
2328
+ // zone to figure out at which index it should be inserted.
2329
+ /** @type {?} */
2330
+ var newIndex = this._getItemIndexFromPointerPosition(item, pointerX, pointerY);
2331
+ /** @type {?} */
2332
+ var currentIndex = this._activeDraggables.indexOf(item);
2333
+ /** @type {?} */
2334
+ var newPositionReference = this._activeDraggables[newIndex];
2335
+ /** @type {?} */
2336
+ var placeholder = item.getPlaceholderElement();
2337
+ // Since the item may be in the `activeDraggables` already (e.g. if the user dragged it
2338
+ // into another container and back again), we have to ensure that it isn't duplicated.
2339
+ if (currentIndex > -1) {
2340
+ this._activeDraggables.splice(currentIndex, 1);
2341
+ }
2342
+ // Don't use items that are being dragged as a reference, because
2343
+ // their element has been moved down to the bottom of the body.
2344
+ if (newPositionReference && !this._dragDropRegistry.isDragging(newPositionReference)) {
2345
+ /** @type {?} */
2346
+ var element = newPositionReference.getRootElement();
2347
+ (/** @type {?} */ (element.parentElement)).insertBefore(placeholder, element);
2348
+ this._activeDraggables.splice(newIndex, 0, item);
2349
+ }
2350
+ else {
2351
+ this.element.nativeElement.appendChild(placeholder);
2352
+ this._activeDraggables.push(item);
2353
+ }
2354
+ // The transform needs to be cleared so it doesn't throw off the measurements.
2355
+ placeholder.style.transform = '';
2356
+ // Note that the positions were already cached when we called `start` above,
2357
+ // but we need to refresh them since the amount of items has changed.
2358
+ this._cachePositions();
2359
+ };
2360
+ /**
2361
+ * Removes an item from the container after it was dragged into another container by the user.
2362
+ * @param item Item that was dragged out.
2363
+ */
2364
+ /**
2365
+ * Removes an item from the container after it was dragged into another container by the user.
2366
+ * @param {?} item Item that was dragged out.
2367
+ * @return {?}
2368
+ */
2369
+ DropListRef.prototype.exit = /**
2370
+ * Removes an item from the container after it was dragged into another container by the user.
2371
+ * @param {?} item Item that was dragged out.
2372
+ * @return {?}
2373
+ */
2374
+ function (item) {
2375
+ this._reset();
2376
+ this.exited.next({ item: item, container: this });
2377
+ };
2378
+ /**
2379
+ * Drops an item into this container.
2380
+ * @param item Item being dropped into the container.
2381
+ * @param currentIndex Index at which the item should be inserted.
2382
+ * @param previousContainer Container from which the item got dragged in.
2383
+ * @param isPointerOverContainer Whether the user's pointer was over the
2384
+ * container when the item was dropped.
2385
+ */
2386
+ /**
2387
+ * Drops an item into this container.
2388
+ * @param {?} item Item being dropped into the container.
2389
+ * @param {?} currentIndex Index at which the item should be inserted.
2390
+ * @param {?} previousContainer Container from which the item got dragged in.
2391
+ * @param {?} isPointerOverContainer Whether the user's pointer was over the
2392
+ * container when the item was dropped.
2393
+ * @return {?}
2394
+ */
2395
+ DropListRef.prototype.drop = /**
2396
+ * Drops an item into this container.
2397
+ * @param {?} item Item being dropped into the container.
2398
+ * @param {?} currentIndex Index at which the item should be inserted.
2399
+ * @param {?} previousContainer Container from which the item got dragged in.
2400
+ * @param {?} isPointerOverContainer Whether the user's pointer was over the
2401
+ * container when the item was dropped.
2402
+ * @return {?}
2403
+ */
2404
+ function (item, currentIndex, previousContainer, isPointerOverContainer) {
2405
+ this._reset();
2406
+ this.dropped.next({
2407
+ item: item,
2408
+ currentIndex: currentIndex,
2409
+ previousIndex: previousContainer.getItemIndex(item),
2410
+ container: this,
2411
+ previousContainer: previousContainer,
2412
+ isPointerOverContainer: isPointerOverContainer
2413
+ });
2414
+ };
2415
+ /**
2416
+ * Sets the draggable items that are a part of this list.
2417
+ * @param items Items that are a part of this list.
2418
+ */
2419
+ /**
2420
+ * Sets the draggable items that are a part of this list.
2421
+ * @template THIS
2422
+ * @this {THIS}
2423
+ * @param {?} items Items that are a part of this list.
2424
+ * @return {THIS}
2425
+ */
2426
+ DropListRef.prototype.withItems = /**
2427
+ * Sets the draggable items that are a part of this list.
2428
+ * @template THIS
2429
+ * @this {THIS}
2430
+ * @param {?} items Items that are a part of this list.
2431
+ * @return {THIS}
2432
+ */
2433
+ function (items) {
2434
+ (/** @type {?} */ (this))._draggables = items.slice();
2435
+ return (/** @type {?} */ (this));
2436
+ };
2437
+ /**
2438
+ * Sets the containers that are connected to this one. When two or more containers are
2439
+ * connected, the user will be allowed to transfer items between them.
2440
+ * @param connectedTo Other containers that the current containers should be connected to.
2441
+ */
2442
+ /**
2443
+ * Sets the containers that are connected to this one. When two or more containers are
2444
+ * connected, the user will be allowed to transfer items between them.
2445
+ * @template THIS
2446
+ * @this {THIS}
2447
+ * @param {?} connectedTo Other containers that the current containers should be connected to.
2448
+ * @return {THIS}
2449
+ */
2450
+ DropListRef.prototype.connectedTo = /**
2451
+ * Sets the containers that are connected to this one. When two or more containers are
2452
+ * connected, the user will be allowed to transfer items between them.
2453
+ * @template THIS
2454
+ * @this {THIS}
2455
+ * @param {?} connectedTo Other containers that the current containers should be connected to.
2456
+ * @return {THIS}
2457
+ */
2458
+ function (connectedTo) {
2459
+ (/** @type {?} */ (this))._siblings = connectedTo.slice();
2460
+ return (/** @type {?} */ (this));
2461
+ };
2462
+ /**
2463
+ * Sets the orientation of the container.
2464
+ * @param orientation New orientation for the container.
2465
+ */
2466
+ /**
2467
+ * Sets the orientation of the container.
2468
+ * @template THIS
2469
+ * @this {THIS}
2470
+ * @param {?} orientation New orientation for the container.
2471
+ * @return {THIS}
2472
+ */
2473
+ DropListRef.prototype.withOrientation = /**
2474
+ * Sets the orientation of the container.
2475
+ * @template THIS
2476
+ * @this {THIS}
2477
+ * @param {?} orientation New orientation for the container.
2478
+ * @return {THIS}
2479
+ */
2480
+ function (orientation) {
2481
+ (/** @type {?} */ (this))._orientation = orientation;
2482
+ return (/** @type {?} */ (this));
2483
+ };
2484
+ /**
2485
+ * Figures out the index of an item in the container.
2486
+ * @param item Item whose index should be determined.
2487
+ */
2488
+ /**
2489
+ * Figures out the index of an item in the container.
2490
+ * @param {?} item Item whose index should be determined.
2491
+ * @return {?}
2492
+ */
2493
+ DropListRef.prototype.getItemIndex = /**
2494
+ * Figures out the index of an item in the container.
2495
+ * @param {?} item Item whose index should be determined.
2496
+ * @return {?}
2497
+ */
2498
+ function (item) {
2499
+ if (!this._isDragging) {
2500
+ return this._draggables.indexOf(item);
2501
+ }
2502
+ // Items are sorted always by top/left in the cache, however they flow differently in RTL.
2503
+ // The rest of the logic still stands no matter what orientation we're in, however
2504
+ // we need to invert the array when determining the index.
2505
+ /** @type {?} */
2506
+ var items = this._orientation === 'horizontal' && this._dir && this._dir.value === 'rtl' ?
2507
+ this._positionCache.items.slice().reverse() : this._positionCache.items;
2508
+ return findIndex(items, function (currentItem) { return currentItem.drag === item; });
2509
+ };
2510
+ /**
2511
+ * Whether the list is able to receive the item that
2512
+ * is currently being dragged inside a connected drop list.
2513
+ */
2514
+ /**
2515
+ * Whether the list is able to receive the item that
2516
+ * is currently being dragged inside a connected drop list.
2517
+ * @return {?}
2518
+ */
2519
+ DropListRef.prototype.isReceiving = /**
2520
+ * Whether the list is able to receive the item that
2521
+ * is currently being dragged inside a connected drop list.
2522
+ * @return {?}
2523
+ */
2524
+ function () {
2525
+ return this._activeSiblings > 0;
2526
+ };
2527
+ /**
2528
+ * Sorts an item inside the container based on its position.
2529
+ * @param item Item to be sorted.
2530
+ * @param pointerX Position of the item along the X axis.
2531
+ * @param pointerY Position of the item along the Y axis.
2532
+ * @param pointerDelta Direction in which the pointer is moving along each axis.
2533
+ */
2534
+ /**
2535
+ * Sorts an item inside the container based on its position.
2536
+ * @param {?} item Item to be sorted.
2537
+ * @param {?} pointerX Position of the item along the X axis.
2538
+ * @param {?} pointerY Position of the item along the Y axis.
2539
+ * @param {?} pointerDelta Direction in which the pointer is moving along each axis.
2540
+ * @return {?}
2541
+ */
2542
+ DropListRef.prototype._sortItem = /**
2543
+ * Sorts an item inside the container based on its position.
2544
+ * @param {?} item Item to be sorted.
2545
+ * @param {?} pointerX Position of the item along the X axis.
2546
+ * @param {?} pointerY Position of the item along the Y axis.
2547
+ * @param {?} pointerDelta Direction in which the pointer is moving along each axis.
2548
+ * @return {?}
2549
+ */
2550
+ function (item, pointerX, pointerY, pointerDelta) {
2551
+ // Don't sort the item if it's out of range.
2552
+ if (!this._isPointerNearDropContainer(pointerX, pointerY)) {
2553
+ return;
2554
+ }
2555
+ /** @type {?} */
2556
+ var siblings = this._positionCache.items;
2557
+ /** @type {?} */
2558
+ var newIndex = this._getItemIndexFromPointerPosition(item, pointerX, pointerY, pointerDelta);
2559
+ if (newIndex === -1 && siblings.length > 0) {
2560
+ return;
2561
+ }
2562
+ /** @type {?} */
2563
+ var isHorizontal = this._orientation === 'horizontal';
2564
+ /** @type {?} */
2565
+ var currentIndex = findIndex(siblings, function (currentItem) { return currentItem.drag === item; });
2566
+ /** @type {?} */
2567
+ var siblingAtNewPosition = siblings[newIndex];
2568
+ /** @type {?} */
2569
+ var currentPosition = siblings[currentIndex].clientRect;
2570
+ /** @type {?} */
2571
+ var newPosition = siblingAtNewPosition.clientRect;
2572
+ /** @type {?} */
2573
+ var delta = currentIndex > newIndex ? 1 : -1;
2574
+ this._previousSwap.drag = siblingAtNewPosition.drag;
2575
+ this._previousSwap.delta = isHorizontal ? pointerDelta.x : pointerDelta.y;
2576
+ // How many pixels the item's placeholder should be offset.
2577
+ /** @type {?} */
2578
+ var itemOffset = this._getItemOffsetPx(currentPosition, newPosition, delta);
2579
+ // How many pixels all the other items should be offset.
2580
+ /** @type {?} */
2581
+ var siblingOffset = this._getSiblingOffsetPx(currentIndex, siblings, delta);
2582
+ // Save the previous order of the items before moving the item to its new index.
2583
+ // We use this to check whether an item has been moved as a result of the sorting.
2584
+ /** @type {?} */
2585
+ var oldOrder = siblings.slice();
2586
+ // Shuffle the array in place.
2587
+ moveItemInArray(siblings, currentIndex, newIndex);
2588
+ this.sorted.next({
2589
+ previousIndex: currentIndex,
2590
+ currentIndex: newIndex,
2591
+ container: this,
2592
+ item: item
2593
+ });
2594
+ siblings.forEach(function (sibling, index) {
2595
+ // Don't do anything if the position hasn't changed.
2596
+ if (oldOrder[index] === sibling) {
2597
+ return;
2598
+ }
2599
+ /** @type {?} */
2600
+ var isDraggedItem = sibling.drag === item;
2601
+ /** @type {?} */
2602
+ var offset = isDraggedItem ? itemOffset : siblingOffset;
2603
+ /** @type {?} */
2604
+ var elementToOffset = isDraggedItem ? item.getPlaceholderElement() :
2605
+ sibling.drag.getRootElement();
2606
+ // Update the offset to reflect the new position.
2607
+ sibling.offset += offset;
2608
+ // Since we're moving the items with a `transform`, we need to adjust their cached
2609
+ // client rects to reflect their new position, as well as swap their positions in the cache.
2610
+ // Note that we shouldn't use `getBoundingClientRect` here to update the cache, because the
2611
+ // elements may be mid-animation which will give us a wrong result.
2612
+ if (isHorizontal) {
2613
+ // Round the transforms since some browsers will
2614
+ // blur the elements, for sub-pixel transforms.
2615
+ elementToOffset.style.transform = "translate3d(" + Math.round(sibling.offset) + "px, 0, 0)";
2616
+ adjustClientRect(sibling.clientRect, 0, offset);
2617
+ }
2618
+ else {
2619
+ elementToOffset.style.transform = "translate3d(0, " + Math.round(sibling.offset) + "px, 0)";
2620
+ adjustClientRect(sibling.clientRect, offset, 0);
2621
+ }
2622
+ });
2623
+ };
2624
+ /** Refreshes the position cache of the items and sibling containers. */
2625
+ /**
2626
+ * Refreshes the position cache of the items and sibling containers.
2627
+ * @private
2628
+ * @return {?}
2629
+ */
2630
+ DropListRef.prototype._cachePositions = /**
2631
+ * Refreshes the position cache of the items and sibling containers.
2632
+ * @private
2633
+ * @return {?}
2634
+ */
2635
+ function () {
2636
+ var _this = this;
2637
+ /** @type {?} */
2638
+ var isHorizontal = this._orientation === 'horizontal';
2639
+ this._positionCache.self = this.element.nativeElement.getBoundingClientRect();
2640
+ this._positionCache.items = this._activeDraggables
2641
+ .map(function (drag) {
2642
+ /** @type {?} */
2643
+ var elementToMeasure = _this._dragDropRegistry.isDragging(drag) ?
2644
+ // If the element is being dragged, we have to measure the
2645
+ // placeholder, because the element is hidden.
2646
+ drag.getPlaceholderElement() :
2647
+ drag.getRootElement();
2648
+ /** @type {?} */
2649
+ var clientRect = elementToMeasure.getBoundingClientRect();
2650
+ return {
2651
+ drag: drag,
2652
+ offset: 0,
2653
+ // We need to clone the `clientRect` here, because all the values on it are readonly
2654
+ // and we need to be able to update them. Also we can't use a spread here, because
2655
+ // the values on a `ClientRect` aren't own properties. See:
2656
+ // https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect#Notes
2657
+ clientRect: {
2658
+ top: clientRect.top,
2659
+ right: clientRect.right,
2660
+ bottom: clientRect.bottom,
2661
+ left: clientRect.left,
2662
+ width: clientRect.width,
2663
+ height: clientRect.height
2664
+ }
2665
+ };
2666
+ })
2667
+ .sort(function (a, b) {
2668
+ return isHorizontal ? a.clientRect.left - b.clientRect.left :
2669
+ a.clientRect.top - b.clientRect.top;
2670
+ });
2671
+ this._positionCache.siblings = this._siblings.map(function (drop) { return ({
2672
+ drop: drop,
2673
+ clientRect: drop.element.nativeElement.getBoundingClientRect()
2674
+ }); });
2675
+ };
2676
+ /**
2677
+ * Toggles whether the list can receive the item that is currently being dragged.
2678
+ * Usually called by a sibling that initiated the dragging.
2679
+ */
2680
+ /**
2681
+ * Toggles whether the list can receive the item that is currently being dragged.
2682
+ * Usually called by a sibling that initiated the dragging.
2683
+ * @param {?} isDragging
2684
+ * @return {?}
2685
+ */
2686
+ DropListRef.prototype._toggleIsReceiving = /**
2687
+ * Toggles whether the list can receive the item that is currently being dragged.
2688
+ * Usually called by a sibling that initiated the dragging.
2689
+ * @param {?} isDragging
2690
+ * @return {?}
2691
+ */
2692
+ function (isDragging) {
2693
+ this._activeSiblings = Math.max(0, this._activeSiblings + (isDragging ? 1 : -1));
2694
+ };
2695
+ /** Resets the container to its initial state. */
2696
+ /**
2697
+ * Resets the container to its initial state.
2698
+ * @private
2699
+ * @return {?}
2700
+ */
2701
+ DropListRef.prototype._reset = /**
2702
+ * Resets the container to its initial state.
2703
+ * @private
2704
+ * @return {?}
2705
+ */
2706
+ function () {
2707
+ this._isDragging = false;
2708
+ // TODO(crisbeto): may have to wait for the animations to finish.
2709
+ this._activeDraggables.forEach(function (item) { return item.getRootElement().style.transform = ''; });
2710
+ this._positionCache.siblings.forEach(function (sibling) { return sibling.drop._toggleIsReceiving(false); });
2711
+ this._activeDraggables = [];
2712
+ this._positionCache.items = [];
2713
+ this._positionCache.siblings = [];
2714
+ this._previousSwap.drag = null;
2715
+ this._previousSwap.delta = 0;
2716
+ };
2717
+ /**
2718
+ * Gets the offset in pixels by which the items that aren't being dragged should be moved.
2719
+ * @param currentIndex Index of the item currently being dragged.
2720
+ * @param siblings All of the items in the list.
2721
+ * @param delta Direction in which the user is moving.
2722
+ */
2723
+ /**
2724
+ * Gets the offset in pixels by which the items that aren't being dragged should be moved.
2725
+ * @private
2726
+ * @param {?} currentIndex Index of the item currently being dragged.
2727
+ * @param {?} siblings All of the items in the list.
2728
+ * @param {?} delta Direction in which the user is moving.
2729
+ * @return {?}
2730
+ */
2731
+ DropListRef.prototype._getSiblingOffsetPx = /**
2732
+ * Gets the offset in pixels by which the items that aren't being dragged should be moved.
2733
+ * @private
2734
+ * @param {?} currentIndex Index of the item currently being dragged.
2735
+ * @param {?} siblings All of the items in the list.
2736
+ * @param {?} delta Direction in which the user is moving.
2737
+ * @return {?}
2738
+ */
2739
+ function (currentIndex, siblings, delta) {
2740
+ /** @type {?} */
2741
+ var isHorizontal = this._orientation === 'horizontal';
2742
+ /** @type {?} */
2743
+ var currentPosition = siblings[currentIndex].clientRect;
2744
+ /** @type {?} */
2745
+ var immediateSibling = siblings[currentIndex + delta * -1];
2746
+ /** @type {?} */
2747
+ var siblingOffset = currentPosition[isHorizontal ? 'width' : 'height'] * delta;
2748
+ if (immediateSibling) {
2749
+ /** @type {?} */
2750
+ var start = isHorizontal ? 'left' : 'top';
2751
+ /** @type {?} */
2752
+ var end = isHorizontal ? 'right' : 'bottom';
2753
+ // Get the spacing between the start of the current item and the end of the one immediately
2754
+ // after it in the direction in which the user is dragging, or vice versa. We add it to the
2755
+ // offset in order to push the element to where it will be when it's inline and is influenced
2756
+ // by the `margin` of its siblings.
2757
+ if (delta === -1) {
2758
+ siblingOffset -= immediateSibling.clientRect[start] - currentPosition[end];
2759
+ }
2760
+ else {
2761
+ siblingOffset += currentPosition[start] - immediateSibling.clientRect[end];
2762
+ }
2763
+ }
2764
+ return siblingOffset;
2765
+ };
2766
+ /**
2767
+ * Checks whether the pointer coordinates are close to the drop container.
2768
+ * @param pointerX Coordinates along the X axis.
2769
+ * @param pointerY Coordinates along the Y axis.
2770
+ */
2771
+ /**
2772
+ * Checks whether the pointer coordinates are close to the drop container.
2773
+ * @private
2774
+ * @param {?} pointerX Coordinates along the X axis.
2775
+ * @param {?} pointerY Coordinates along the Y axis.
2776
+ * @return {?}
2777
+ */
2778
+ DropListRef.prototype._isPointerNearDropContainer = /**
2779
+ * Checks whether the pointer coordinates are close to the drop container.
2780
+ * @private
2781
+ * @param {?} pointerX Coordinates along the X axis.
2782
+ * @param {?} pointerY Coordinates along the Y axis.
2783
+ * @return {?}
2784
+ */
2785
+ function (pointerX, pointerY) {
2786
+ var _a = this._positionCache.self, top = _a.top, right = _a.right, bottom = _a.bottom, left = _a.left, width = _a.width, height = _a.height;
2787
+ /** @type {?} */
2788
+ var xThreshold = width * DROP_PROXIMITY_THRESHOLD;
2789
+ /** @type {?} */
2790
+ var yThreshold = height * DROP_PROXIMITY_THRESHOLD;
2791
+ return pointerY > top - yThreshold && pointerY < bottom + yThreshold &&
2792
+ pointerX > left - xThreshold && pointerX < right + xThreshold;
2793
+ };
2794
+ /**
2795
+ * Gets the offset in pixels by which the item that is being dragged should be moved.
2796
+ * @param currentPosition Current position of the item.
2797
+ * @param newPosition Position of the item where the current item should be moved.
2798
+ * @param delta Direction in which the user is moving.
2799
+ */
2800
+ /**
2801
+ * Gets the offset in pixels by which the item that is being dragged should be moved.
2802
+ * @private
2803
+ * @param {?} currentPosition Current position of the item.
2804
+ * @param {?} newPosition Position of the item where the current item should be moved.
2805
+ * @param {?} delta Direction in which the user is moving.
2806
+ * @return {?}
2807
+ */
2808
+ DropListRef.prototype._getItemOffsetPx = /**
2809
+ * Gets the offset in pixels by which the item that is being dragged should be moved.
2810
+ * @private
2811
+ * @param {?} currentPosition Current position of the item.
2812
+ * @param {?} newPosition Position of the item where the current item should be moved.
2813
+ * @param {?} delta Direction in which the user is moving.
2814
+ * @return {?}
2815
+ */
2816
+ function (currentPosition, newPosition, delta) {
2817
+ /** @type {?} */
2818
+ var isHorizontal = this._orientation === 'horizontal';
2819
+ /** @type {?} */
2820
+ var itemOffset = isHorizontal ? newPosition.left - currentPosition.left :
2821
+ newPosition.top - currentPosition.top;
2822
+ // Account for differences in the item width/height.
2823
+ if (delta === -1) {
2824
+ itemOffset += isHorizontal ? newPosition.width - currentPosition.width :
2825
+ newPosition.height - currentPosition.height;
2826
+ }
2827
+ return itemOffset;
2828
+ };
2829
+ /**
2830
+ * Gets the index of an item in the drop container, based on the position of the user's pointer.
2831
+ * @param item Item that is being sorted.
2832
+ * @param pointerX Position of the user's pointer along the X axis.
2833
+ * @param pointerY Position of the user's pointer along the Y axis.
2834
+ * @param delta Direction in which the user is moving their pointer.
2835
+ */
2836
+ /**
2837
+ * Gets the index of an item in the drop container, based on the position of the user's pointer.
2838
+ * @private
2839
+ * @param {?} item Item that is being sorted.
2840
+ * @param {?} pointerX Position of the user's pointer along the X axis.
2841
+ * @param {?} pointerY Position of the user's pointer along the Y axis.
2842
+ * @param {?=} delta Direction in which the user is moving their pointer.
2843
+ * @return {?}
2844
+ */
2845
+ DropListRef.prototype._getItemIndexFromPointerPosition = /**
2846
+ * Gets the index of an item in the drop container, based on the position of the user's pointer.
2847
+ * @private
2848
+ * @param {?} item Item that is being sorted.
2849
+ * @param {?} pointerX Position of the user's pointer along the X axis.
2850
+ * @param {?} pointerY Position of the user's pointer along the Y axis.
2851
+ * @param {?=} delta Direction in which the user is moving their pointer.
2852
+ * @return {?}
2853
+ */
2854
+ function (item, pointerX, pointerY, delta) {
2855
+ var _this = this;
2856
+ /** @type {?} */
2857
+ var isHorizontal = this._orientation === 'horizontal';
2858
+ return findIndex(this._positionCache.items, function (_a, _, array) {
2859
+ var drag = _a.drag, clientRect = _a.clientRect;
2860
+ if (drag === item) {
2861
+ // If there's only one item left in the container, it must be
2862
+ // the dragged item itself so we use it as a reference.
2863
+ return array.length < 2;
2864
+ }
2865
+ if (delta) {
2866
+ /** @type {?} */
2867
+ var direction = isHorizontal ? delta.x : delta.y;
2868
+ // If the user is still hovering over the same item as last time, and they didn't change
2869
+ // the direction in which they're dragging, we don't consider it a direction swap.
2870
+ if (drag === _this._previousSwap.drag && direction === _this._previousSwap.delta) {
2871
+ return false;
2872
+ }
2873
+ }
2874
+ return isHorizontal ?
2875
+ // Round these down since most browsers report client rects with
2876
+ // sub-pixel precision, whereas the pointer coordinates are rounded to pixels.
2877
+ pointerX >= Math.floor(clientRect.left) && pointerX <= Math.floor(clientRect.right) :
2878
+ pointerY >= Math.floor(clientRect.top) && pointerY <= Math.floor(clientRect.bottom);
2879
+ });
2880
+ };
2881
+ /**
2882
+ * Checks whether the user's pointer is positioned over the container.
2883
+ * @param x Pointer position along the X axis.
2884
+ * @param y Pointer position along the Y axis.
2885
+ */
2886
+ /**
2887
+ * Checks whether the user's pointer is positioned over the container.
2888
+ * @param {?} x Pointer position along the X axis.
2889
+ * @param {?} y Pointer position along the Y axis.
2890
+ * @return {?}
2891
+ */
2892
+ DropListRef.prototype._isOverContainer = /**
2893
+ * Checks whether the user's pointer is positioned over the container.
2894
+ * @param {?} x Pointer position along the X axis.
2895
+ * @param {?} y Pointer position along the Y axis.
2896
+ * @return {?}
2897
+ */
2898
+ function (x, y) {
2899
+ return isInsideClientRect(this._positionCache.self, x, y);
2900
+ };
2901
+ /**
2902
+ * Figures out whether an item should be moved into a sibling
2903
+ * drop container, based on its current position.
2904
+ * @param item Drag item that is being moved.
2905
+ * @param x Position of the item along the X axis.
2906
+ * @param y Position of the item along the Y axis.
2907
+ */
2908
+ /**
2909
+ * Figures out whether an item should be moved into a sibling
2910
+ * drop container, based on its current position.
2911
+ * @param {?} item Drag item that is being moved.
2912
+ * @param {?} x Position of the item along the X axis.
2913
+ * @param {?} y Position of the item along the Y axis.
2914
+ * @return {?}
2915
+ */
2916
+ DropListRef.prototype._getSiblingContainerFromPosition = /**
2917
+ * Figures out whether an item should be moved into a sibling
2918
+ * drop container, based on its current position.
2919
+ * @param {?} item Drag item that is being moved.
2920
+ * @param {?} x Position of the item along the X axis.
2921
+ * @param {?} y Position of the item along the Y axis.
2922
+ * @return {?}
2923
+ */
2924
+ function (item, x, y) {
2925
+ /** @type {?} */
2926
+ var results = this._positionCache.siblings.filter(function (sibling) {
2927
+ return isInsideClientRect(sibling.clientRect, x, y);
2928
+ });
2929
+ // No drop containers are intersecting with the pointer.
2930
+ if (!results.length) {
2931
+ return null;
2932
+ }
2933
+ /** @type {?} */
2934
+ var elementFromPoint = this._document.elementFromPoint(x, y);
2935
+ // If there's no element at the pointer position, then
2936
+ // the client rect is probably scrolled out of the view.
2937
+ if (!elementFromPoint) {
2938
+ return null;
2939
+ }
2940
+ // The `ClientRect`, that we're using to find the container over which the user is
2941
+ // hovering, doesn't give us any information on whether the element has been scrolled
2942
+ // out of the view or whether it's overlapping with other containers. This means that
2943
+ // we could end up transferring the item into a container that's invisible or is positioned
2944
+ // below another one. We use the result from `elementFromPoint` to get the top-most element
2945
+ // at the pointer position and to find whether it's one of the intersecting drop containers.
2946
+ /** @type {?} */
2947
+ var result = results.find(function (sibling) {
2948
+ /** @type {?} */
2949
+ var element = sibling.drop.element.nativeElement;
2950
+ return element === elementFromPoint || element.contains(elementFromPoint);
2951
+ });
2952
+ return result && result.drop.enterPredicate(item, result.drop) ? result.drop : null;
2953
+ };
2954
+ return DropListRef;
2955
+ }());
2956
+ /**
2957
+ * Updates the top/left positions of a `ClientRect`, as well as their bottom/right counterparts.
2958
+ * @param {?} clientRect `ClientRect` that should be updated.
2959
+ * @param {?} top Amount to add to the `top` position.
2960
+ * @param {?} left Amount to add to the `left` position.
2961
+ * @return {?}
2962
+ */
2963
+ function adjustClientRect(clientRect, top, left) {
2964
+ clientRect.top += top;
2965
+ clientRect.bottom = clientRect.top + clientRect.height;
2966
+ clientRect.left += left;
2967
+ clientRect.right = clientRect.left + clientRect.width;
2968
+ }
2969
+ /**
2970
+ * Finds the index of an item that matches a predicate function. Used as an equivalent
2971
+ * of `Array.prototype.find` which isn't part of the standard Google typings.
2972
+ * @template T
2973
+ * @param {?} array Array in which to look for matches.
2974
+ * @param {?} predicate Function used to determine whether an item is a match.
2975
+ * @return {?}
2976
+ */
2977
+ function findIndex(array, predicate) {
2978
+ for (var i = 0; i < array.length; i++) {
2979
+ if (predicate(array[i], i, array)) {
2980
+ return i;
2981
+ }
2982
+ }
2983
+ return -1;
2984
+ }
2985
+ /**
2986
+ * Checks whether some coordinates are within a `ClientRect`.
2987
+ * @param {?} clientRect ClientRect that is being checked.
2988
+ * @param {?} x Coordinates along the X axis.
2989
+ * @param {?} y Coordinates along the Y axis.
2990
+ * @return {?}
2991
+ */
2992
+ function isInsideClientRect(clientRect, x, y) {
2993
+ var top = clientRect.top, bottom = clientRect.bottom, left = clientRect.left, right = clientRect.right;
2994
+ return y >= top && y <= bottom && x >= left && x <= right;
2995
+ }
2996
+
2997
+ /**
2998
+ * @fileoverview added by tsickle
2999
+ * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3000
+ */
3001
+ /**
3002
+ * Counter used to generate unique ids for drop zones.
3003
+ * @type {?}
3004
+ */
3005
+ var _uniqueIdCounter$1 = 0;
3006
+ var ɵ0 = undefined;
3007
+ // @breaking-change 8.0.0 `CdkDropList` implements `CdkDropListContainer` for backwards
3008
+ // compatiblity. The implements clause, as well as all the methods that it enforces can
3009
+ // be removed when `CdkDropListContainer` is deleted.
3010
+ /**
3011
+ * Container that wraps a set of draggable items.
3012
+ * @template T
3013
+ */
3014
+ var CdkDropList = /** @class */ (function () {
3015
+ function CdkDropList(element, dragDropRegistry, _changeDetectorRef, dir, _group,
3016
+ // @breaking-change 8.0.0 `_document` parameter to be made required.
3017
+ _document) {
3018
+ var _this = this;
3019
+ this.element = element;
3020
+ this._changeDetectorRef = _changeDetectorRef;
3021
+ this._group = _group;
3022
+ /**
3023
+ * Other draggable containers that this container is connected to and into which the
3024
+ * container's items can be transferred. Can either be references to other drop containers,
3025
+ * or their unique IDs.
3026
+ */
3027
+ this.connectedTo = [];
3028
+ /**
3029
+ * Direction in which the list is oriented.
3030
+ */
3031
+ this.orientation = 'vertical';
3032
+ /**
3033
+ * Unique ID for the drop zone. Can be used as a reference
3034
+ * in the `connectedTo` of another `CdkDropList`.
3035
+ */
3036
+ this.id = "cdk-drop-list-" + _uniqueIdCounter$1++;
3037
+ this._disabled = false;
3038
+ /**
3039
+ * Function that is used to determine whether an item
3040
+ * is allowed to be moved into a drop container.
3041
+ */
3042
+ this.enterPredicate = function () { return true; };
3043
+ /**
3044
+ * Emits when the user drops an item inside the container.
3045
+ */
3046
+ this.dropped = new EventEmitter();
3047
+ /**
3048
+ * Emits when the user has moved a new drag item into this container.
3049
+ */
3050
+ this.entered = new EventEmitter();
3051
+ /**
3052
+ * Emits when the user removes an item from the container
3053
+ * by dragging it into another container.
3054
+ */
3055
+ this.exited = new EventEmitter();
3056
+ /**
3057
+ * Emits as the user is swapping items while actively dragging.
3058
+ */
3059
+ this.sorted = new EventEmitter();
3060
+ // @breaking-change 8.0.0 Remove || once `_document` parameter is required.
3061
+ /** @type {?} */
3062
+ var ref = this._dropListRef = new DropListRef(element, dragDropRegistry, _document || document, dir);
3063
+ ref.data = this;
3064
+ ref.enterPredicate = function (drag, drop) {
3065
+ return _this.enterPredicate(drag.data, drop.data);
3066
+ };
3067
+ this._syncInputs(ref);
3068
+ this._proxyEvents(ref);
3069
+ CdkDropList._dropLists.push(this);
3070
+ if (_group) {
3071
+ _group._items.add(this);
3072
+ }
3073
+ }
3074
+ Object.defineProperty(CdkDropList.prototype, "disabled", {
3075
+ /** Whether starting a dragging sequence from this container is disabled. */
3076
+ get: /**
3077
+ * Whether starting a dragging sequence from this container is disabled.
3078
+ * @return {?}
3079
+ */
3080
+ function () {
3081
+ return this._disabled || (!!this._group && this._group.disabled);
3082
+ },
3083
+ set: /**
3084
+ * @param {?} value
3085
+ * @return {?}
3086
+ */
3087
+ function (value) {
3088
+ this._disabled = coerceBooleanProperty(value);
3089
+ },
3090
+ enumerable: true,
3091
+ configurable: true
3092
+ });
3093
+ /**
3094
+ * @return {?}
3095
+ */
3096
+ CdkDropList.prototype.ngOnDestroy = /**
3097
+ * @return {?}
3098
+ */
3099
+ function () {
3100
+ /** @type {?} */
3101
+ var index = CdkDropList._dropLists.indexOf(this);
3102
+ this._dropListRef.dispose();
3103
+ if (index > -1) {
3104
+ CdkDropList._dropLists.splice(index, 1);
3105
+ }
3106
+ if (this._group) {
3107
+ this._group._items.delete(this);
1563
3108
  }
1564
3109
  };
1565
3110
  /** Starts dragging an item. */
@@ -1572,22 +3117,23 @@ var CdkDropList = /** @class */ (function () {
1572
3117
  * @return {?}
1573
3118
  */
1574
3119
  function () {
1575
- this._dragging = true;
1576
- this._activeDraggables = this._draggables.toArray();
1577
- this._cachePositions();
1578
- this._changeDetectorRef.markForCheck();
3120
+ this._dropListRef.start();
1579
3121
  };
1580
3122
  /**
1581
3123
  * Drops an item into this container.
1582
3124
  * @param item Item being dropped into the container.
1583
3125
  * @param currentIndex Index at which the item should be inserted.
1584
3126
  * @param previousContainer Container from which the item got dragged in.
3127
+ * @param isPointerOverContainer Whether the user's pointer was over the
3128
+ * container when the item was dropped.
1585
3129
  */
1586
3130
  /**
1587
3131
  * Drops an item into this container.
1588
3132
  * @param {?} item Item being dropped into the container.
1589
3133
  * @param {?} currentIndex Index at which the item should be inserted.
1590
3134
  * @param {?} previousContainer Container from which the item got dragged in.
3135
+ * @param {?} isPointerOverContainer Whether the user's pointer was over the
3136
+ * container when the item was dropped.
1591
3137
  * @return {?}
1592
3138
  */
1593
3139
  CdkDropList.prototype.drop = /**
@@ -1595,18 +3141,12 @@ var CdkDropList = /** @class */ (function () {
1595
3141
  * @param {?} item Item being dropped into the container.
1596
3142
  * @param {?} currentIndex Index at which the item should be inserted.
1597
3143
  * @param {?} previousContainer Container from which the item got dragged in.
3144
+ * @param {?} isPointerOverContainer Whether the user's pointer was over the
3145
+ * container when the item was dropped.
1598
3146
  * @return {?}
1599
3147
  */
1600
- function (item, currentIndex, previousContainer) {
1601
- this._reset();
1602
- this.dropped.emit({
1603
- item: item,
1604
- currentIndex: currentIndex,
1605
- previousIndex: previousContainer.getItemIndex(item),
1606
- container: this,
1607
- // TODO(crisbeto): reconsider whether to make this null if the containers are the same.
1608
- previousContainer: previousContainer
1609
- });
3148
+ function (item, currentIndex, previousContainer, isPointerOverContainer) {
3149
+ this._dropListRef.drop(item._dragRef, currentIndex, ((/** @type {?} */ (previousContainer)))._dropListRef, isPointerOverContainer);
1610
3150
  };
1611
3151
  /**
1612
3152
  * Emits an event to indicate that the user moved an item into the container.
@@ -1629,38 +3169,7 @@ var CdkDropList = /** @class */ (function () {
1629
3169
  * @return {?}
1630
3170
  */
1631
3171
  function (item, pointerX, pointerY) {
1632
- this.entered.emit({ item: item, container: this });
1633
- this.start();
1634
- /** @type {?} */
1635
- var newIndex = this._getItemIndexFromPointerPosition(item, pointerX, pointerY);
1636
- /** @type {?} */
1637
- var currentIndex = this._activeDraggables.indexOf(item);
1638
- /** @type {?} */
1639
- var newPositionReference = this._activeDraggables[newIndex];
1640
- /** @type {?} */
1641
- var placeholder = item.getPlaceholderElement();
1642
- // Since the item may be in the `activeDraggables` already (e.g. if the user dragged it
1643
- // into another container and back again), we have to ensure that it isn't duplicated.
1644
- if (currentIndex > -1) {
1645
- this._activeDraggables.splice(currentIndex, 1);
1646
- }
1647
- // Don't use items that are being dragged as a reference, because
1648
- // their element has been moved down to the bottom of the body.
1649
- if (newPositionReference && !this._dragDropRegistry.isDragging(newPositionReference)) {
1650
- /** @type {?} */
1651
- var element = newPositionReference.getRootElement(); /** @type {?} */
1652
- ((element.parentElement)).insertBefore(placeholder, element);
1653
- this._activeDraggables.splice(newIndex, 0, item);
1654
- }
1655
- else {
1656
- this.element.nativeElement.appendChild(placeholder);
1657
- this._activeDraggables.push(item);
1658
- }
1659
- // The transform needs to be cleared so it doesn't throw off the measurements.
1660
- placeholder.style.transform = '';
1661
- // Note that the positions were already cached when we called `start` above,
1662
- // but we need to refresh them since the amount of items has changed.
1663
- this._cachePositions();
3172
+ this._dropListRef.enter(item._dragRef, pointerX, pointerY);
1664
3173
  };
1665
3174
  /**
1666
3175
  * Removes an item from the container after it was dragged into another container by the user.
@@ -1677,8 +3186,7 @@ var CdkDropList = /** @class */ (function () {
1677
3186
  * @return {?}
1678
3187
  */
1679
3188
  function (item) {
1680
- this._reset();
1681
- this.exited.emit({ item: item, container: this });
3189
+ this._dropListRef.exit(item._dragRef);
1682
3190
  };
1683
3191
  /**
1684
3192
  * Figures out the index of an item in the container.
@@ -1695,105 +3203,33 @@ var CdkDropList = /** @class */ (function () {
1695
3203
  * @return {?}
1696
3204
  */
1697
3205
  function (item) {
1698
- if (!this._dragging) {
1699
- return this._draggables.toArray().indexOf(item);
1700
- }
1701
- /** @type {?} */
1702
- var items = this.orientation === 'horizontal' && this._dir && this._dir.value === 'rtl' ?
1703
- this._positionCache.items.slice().reverse() : this._positionCache.items;
1704
- return findIndex(items, function (currentItem) { return currentItem.drag === item; });
1705
- };
1706
- /**
1707
- * Sorts an item inside the container based on its position.
1708
- * @param item Item to be sorted.
1709
- * @param pointerX Position of the item along the X axis.
1710
- * @param pointerY Position of the item along the Y axis.
1711
- * @param pointerDeta Direction in which the pointer is moving along each axis.
1712
- */
1713
- /**
1714
- * Sorts an item inside the container based on its position.
1715
- * @param {?} item Item to be sorted.
1716
- * @param {?} pointerX Position of the item along the X axis.
1717
- * @param {?} pointerY Position of the item along the Y axis.
1718
- * @param {?} pointerDelta
1719
- * @return {?}
1720
- */
1721
- CdkDropList.prototype._sortItem = /**
1722
- * Sorts an item inside the container based on its position.
1723
- * @param {?} item Item to be sorted.
1724
- * @param {?} pointerX Position of the item along the X axis.
1725
- * @param {?} pointerY Position of the item along the Y axis.
1726
- * @param {?} pointerDelta
1727
- * @return {?}
1728
- */
1729
- function (item, pointerX, pointerY, pointerDelta) {
1730
- var _this = this;
1731
- // Don't sort the item if it's out of range.
1732
- if (!this._isPointerNearDropContainer(pointerX, pointerY)) {
1733
- return;
1734
- }
1735
- /** @type {?} */
1736
- var siblings = this._positionCache.items;
1737
- /** @type {?} */
1738
- var newIndex = this._getItemIndexFromPointerPosition(item, pointerX, pointerY, pointerDelta);
1739
- if (newIndex === -1 && siblings.length > 0) {
1740
- return;
1741
- }
1742
- /** @type {?} */
1743
- var isHorizontal = this.orientation === 'horizontal';
1744
- /** @type {?} */
1745
- var currentIndex = findIndex(siblings, function (currentItem) { return currentItem.drag === item; });
1746
- /** @type {?} */
1747
- var siblingAtNewPosition = siblings[newIndex];
1748
- /** @type {?} */
1749
- var currentPosition = siblings[currentIndex].clientRect;
1750
- /** @type {?} */
1751
- var newPosition = siblingAtNewPosition.clientRect;
1752
- /** @type {?} */
1753
- var delta = currentIndex > newIndex ? 1 : -1;
1754
- this._previousSwap.drag = siblingAtNewPosition.drag;
1755
- this._previousSwap.delta = isHorizontal ? pointerDelta.x : pointerDelta.y;
1756
- /** @type {?} */
1757
- var itemOffset = this._getItemOffsetPx(currentPosition, newPosition, delta);
1758
- /** @type {?} */
1759
- var siblingOffset = this._getSiblingOffsetPx(currentIndex, siblings, delta);
1760
- /** @type {?} */
1761
- var oldOrder = siblings.slice();
1762
- // Shuffle the array in place.
1763
- moveItemInArray(siblings, currentIndex, newIndex);
1764
- this.sorted.emit({
1765
- previousIndex: currentIndex,
1766
- currentIndex: newIndex,
1767
- container: this,
1768
- item: item
1769
- });
1770
- siblings.forEach(function (sibling, index) {
1771
- // Don't do anything if the position hasn't changed.
1772
- if (oldOrder[index] === sibling) {
1773
- return;
1774
- }
1775
- /** @type {?} */
1776
- var isDraggedItem = sibling.drag === item;
1777
- /** @type {?} */
1778
- var offset = isDraggedItem ? itemOffset : siblingOffset;
1779
- /** @type {?} */
1780
- var elementToOffset = isDraggedItem ? item.getPlaceholderElement() :
1781
- sibling.drag.getRootElement();
1782
- // Update the offset to reflect the new position.
1783
- sibling.offset += offset;
1784
- // Since we're moving the items with a `transform`, we need to adjust their cached
1785
- // client rects to reflect their new position, as well as swap their positions in the cache.
1786
- // Note that we shouldn't use `getBoundingClientRect` here to update the cache, because the
1787
- // elements may be mid-animation which will give us a wrong result.
1788
- if (isHorizontal) {
1789
- elementToOffset.style.transform = "translate3d(" + sibling.offset + "px, 0, 0)";
1790
- _this._adjustClientRect(sibling.clientRect, 0, offset);
1791
- }
1792
- else {
1793
- elementToOffset.style.transform = "translate3d(0, " + sibling.offset + "px, 0)";
1794
- _this._adjustClientRect(sibling.clientRect, offset, 0);
1795
- }
1796
- });
3206
+ return this._dropListRef.getItemIndex(item._dragRef);
3207
+ };
3208
+ /**
3209
+ * Sorts an item inside the container based on its position.
3210
+ * @param item Item to be sorted.
3211
+ * @param pointerX Position of the item along the X axis.
3212
+ * @param pointerY Position of the item along the Y axis.
3213
+ * @param pointerDelta Direction in which the pointer is moving along each axis.
3214
+ */
3215
+ /**
3216
+ * Sorts an item inside the container based on its position.
3217
+ * @param {?} item Item to be sorted.
3218
+ * @param {?} pointerX Position of the item along the X axis.
3219
+ * @param {?} pointerY Position of the item along the Y axis.
3220
+ * @param {?} pointerDelta Direction in which the pointer is moving along each axis.
3221
+ * @return {?}
3222
+ */
3223
+ CdkDropList.prototype._sortItem = /**
3224
+ * Sorts an item inside the container based on its position.
3225
+ * @param {?} item Item to be sorted.
3226
+ * @param {?} pointerX Position of the item along the X axis.
3227
+ * @param {?} pointerY Position of the item along the Y axis.
3228
+ * @param {?} pointerDelta Direction in which the pointer is moving along each axis.
3229
+ * @return {?}
3230
+ */
3231
+ function (item, pointerX, pointerY, pointerDelta) {
3232
+ return this._dropListRef._sortItem(item._dragRef, pointerX, pointerY, pointerDelta);
1797
3233
  };
1798
3234
  /**
1799
3235
  * Figures out whether an item should be moved into a sibling
@@ -1820,286 +3256,136 @@ var CdkDropList = /** @class */ (function () {
1820
3256
  */
1821
3257
  function (item, x, y) {
1822
3258
  /** @type {?} */
1823
- var result = this._positionCache.siblings
1824
- .find(function (sibling) { return isInsideClientRect(sibling.clientRect, x, y); });
1825
- return result && result.drop.enterPredicate(item, result.drop) ? result.drop : null;
3259
+ var result = this._dropListRef._getSiblingContainerFromPosition(item._dragRef, x, y);
3260
+ return result ? result.data : null;
1826
3261
  };
1827
3262
  /**
1828
- * Checks whether an item that started in this container can be returned to it,
1829
- * after it was moved out into another container.
1830
- * @param x Position of the item along the X axis.
1831
- * @param y Position of the item along the Y axis.
3263
+ * Checks whether the user's pointer is positioned over the container.
3264
+ * @param x Pointer position along the X axis.
3265
+ * @param y Pointer position along the Y axis.
1832
3266
  */
1833
3267
  /**
1834
- * Checks whether an item that started in this container can be returned to it,
1835
- * after it was moved out into another container.
1836
- * @param {?} x Position of the item along the X axis.
1837
- * @param {?} y Position of the item along the Y axis.
3268
+ * Checks whether the user's pointer is positioned over the container.
3269
+ * @param {?} x Pointer position along the X axis.
3270
+ * @param {?} y Pointer position along the Y axis.
1838
3271
  * @return {?}
1839
3272
  */
1840
- CdkDropList.prototype._canReturnItem = /**
1841
- * Checks whether an item that started in this container can be returned to it,
1842
- * after it was moved out into another container.
1843
- * @param {?} x Position of the item along the X axis.
1844
- * @param {?} y Position of the item along the Y axis.
3273
+ CdkDropList.prototype._isOverContainer = /**
3274
+ * Checks whether the user's pointer is positioned over the container.
3275
+ * @param {?} x Pointer position along the X axis.
3276
+ * @param {?} y Pointer position along the Y axis.
1845
3277
  * @return {?}
1846
3278
  */
1847
3279
  function (x, y) {
1848
- return isInsideClientRect(this._positionCache.self, x, y);
3280
+ return this._dropListRef._isOverContainer(x, y);
1849
3281
  };
3282
+ /** Syncs the inputs of the CdkDropList with the options of the underlying DropListRef. */
1850
3283
  /**
1851
- * Refreshes the position cache of the items and sibling containers.
3284
+ * Syncs the inputs of the CdkDropList with the options of the underlying DropListRef.
3285
+ * @private
3286
+ * @param {?} ref
1852
3287
  * @return {?}
1853
3288
  */
1854
- CdkDropList.prototype._cachePositions = /**
1855
- * Refreshes the position cache of the items and sibling containers.
3289
+ CdkDropList.prototype._syncInputs = /**
3290
+ * Syncs the inputs of the CdkDropList with the options of the underlying DropListRef.
3291
+ * @private
3292
+ * @param {?} ref
1856
3293
  * @return {?}
1857
3294
  */
1858
- function () {
3295
+ function (ref) {
1859
3296
  var _this = this;
1860
- /** @type {?} */
1861
- var isHorizontal = this.orientation === 'horizontal';
1862
- this._positionCache.self = this.element.nativeElement.getBoundingClientRect();
1863
- this._positionCache.items = this._activeDraggables
1864
- .map(function (drag) {
1865
- /** @type {?} */
1866
- var elementToMeasure = _this._dragDropRegistry.isDragging(drag) ?
1867
- // If the element is being dragged, we have to measure the
1868
- // placeholder, because the element is hidden.
1869
- drag.getPlaceholderElement() :
1870
- drag.getRootElement();
3297
+ ref.beforeStarted.subscribe(function () {
1871
3298
  /** @type {?} */
1872
- var clientRect = elementToMeasure.getBoundingClientRect();
1873
- return {
1874
- drag: drag,
1875
- offset: 0,
1876
- // We need to clone the `clientRect` here, because all the values on it are readonly
1877
- // and we need to be able to update them. Also we can't use a spread here, because
1878
- // the values on a `ClientRect` aren't own properties. See:
1879
- // https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect#Notes
1880
- clientRect: {
1881
- top: clientRect.top,
1882
- right: clientRect.right,
1883
- bottom: clientRect.bottom,
1884
- left: clientRect.left,
1885
- width: clientRect.width,
1886
- height: clientRect.height
1887
- }
1888
- };
1889
- })
1890
- .sort(function (a, b) {
1891
- return isHorizontal ? a.clientRect.left - b.clientRect.left :
1892
- a.clientRect.top - b.clientRect.top;
1893
- });
1894
- this._positionCache.siblings = this._getConnectedLists().map(function (drop) { return ({
1895
- drop: drop,
1896
- clientRect: drop.element.nativeElement.getBoundingClientRect()
1897
- }); });
1898
- };
1899
- /**
1900
- * Resets the container to its initial state.
1901
- * @return {?}
1902
- */
1903
- CdkDropList.prototype._reset = /**
1904
- * Resets the container to its initial state.
1905
- * @return {?}
1906
- */
1907
- function () {
1908
- this._dragging = false;
1909
- // TODO(crisbeto): may have to wait for the animations to finish.
1910
- this._activeDraggables.forEach(function (item) { return item.getRootElement().style.transform = ''; });
1911
- this._activeDraggables = [];
1912
- this._positionCache.items = [];
1913
- this._positionCache.siblings = [];
1914
- this._previousSwap.drag = null;
1915
- this._previousSwap.delta = 0;
1916
- };
1917
- /**
1918
- * Updates the top/left positions of a `ClientRect`, as well as their bottom/right counterparts.
1919
- * @param {?} clientRect `ClientRect` that should be updated.
1920
- * @param {?} top Amount to add to the `top` position.
1921
- * @param {?} left Amount to add to the `left` position.
1922
- * @return {?}
1923
- */
1924
- CdkDropList.prototype._adjustClientRect = /**
1925
- * Updates the top/left positions of a `ClientRect`, as well as their bottom/right counterparts.
1926
- * @param {?} clientRect `ClientRect` that should be updated.
1927
- * @param {?} top Amount to add to the `top` position.
1928
- * @param {?} left Amount to add to the `left` position.
1929
- * @return {?}
1930
- */
1931
- function (clientRect, top, left) {
1932
- clientRect.top += top;
1933
- clientRect.bottom = clientRect.top + clientRect.height;
1934
- clientRect.left += left;
1935
- clientRect.right = clientRect.left + clientRect.width;
1936
- };
1937
- /**
1938
- * Gets the index of an item in the drop container, based on the position of the user's pointer.
1939
- * @param {?} item Item that is being sorted.
1940
- * @param {?} pointerX Position of the user's pointer along the X axis.
1941
- * @param {?} pointerY Position of the user's pointer along the Y axis.
1942
- * @param {?=} delta Direction in which the user is moving their pointer.
1943
- * @return {?}
1944
- */
1945
- CdkDropList.prototype._getItemIndexFromPointerPosition = /**
1946
- * Gets the index of an item in the drop container, based on the position of the user's pointer.
1947
- * @param {?} item Item that is being sorted.
1948
- * @param {?} pointerX Position of the user's pointer along the X axis.
1949
- * @param {?} pointerY Position of the user's pointer along the Y axis.
1950
- * @param {?=} delta Direction in which the user is moving their pointer.
1951
- * @return {?}
1952
- */
1953
- function (item, pointerX, pointerY, delta) {
1954
- var _this = this;
1955
- /** @type {?} */
1956
- var isHorizontal = this.orientation === 'horizontal';
1957
- return findIndex(this._positionCache.items, function (_a, _, array) {
1958
- var drag = _a.drag, clientRect = _a.clientRect;
1959
- if (drag === item) {
1960
- // If there's only one item left in the container, it must be
1961
- // the dragged item itself so we use it as a reference.
1962
- return array.length < 2;
1963
- }
1964
- if (delta) {
1965
- /** @type {?} */
1966
- var direction = isHorizontal ? delta.x : delta.y;
1967
- // If the user is still hovering over the same item as last time, and they didn't change
1968
- // the direction in which they're dragging, we don't consider it a direction swap.
1969
- if (drag === _this._previousSwap.drag && direction === _this._previousSwap.delta) {
1970
- return false;
1971
- }
3299
+ var siblings = coerceArray(_this.connectedTo).map(function (drop) {
3300
+ return typeof drop === 'string' ?
3301
+ (/** @type {?} */ (CdkDropList._dropLists.find(function (list) { return list.id === drop; }))) : drop;
3302
+ });
3303
+ if (_this._group) {
3304
+ _this._group._items.forEach(function (drop) {
3305
+ if (siblings.indexOf(drop) === -1) {
3306
+ siblings.push(drop);
3307
+ }
3308
+ });
1972
3309
  }
1973
- return isHorizontal ?
1974
- // Round these down since most browsers report client rects with
1975
- // sub-pixel precision, whereas the pointer coordinates are rounded to pixels.
1976
- pointerX >= Math.floor(clientRect.left) && pointerX <= Math.floor(clientRect.right) :
1977
- pointerY >= Math.floor(clientRect.top) && pointerY <= Math.floor(clientRect.bottom);
3310
+ ref.lockAxis = _this.lockAxis;
3311
+ ref
3312
+ .connectedTo(siblings.filter(function (drop) { return drop && drop !== _this; }).map(function (list) { return list._dropListRef; }))
3313
+ .withOrientation(_this.orientation)
3314
+ .withItems(_this._draggables.map(function (drag) { return drag._dragRef; }));
1978
3315
  });
1979
3316
  };
1980
3317
  /**
1981
- * Checks whether the pointer coordinates are close to the drop container.
1982
- * @param {?} pointerX Coordinates along the X axis.
1983
- * @param {?} pointerY Coordinates along the Y axis.
1984
- * @return {?}
1985
- */
1986
- CdkDropList.prototype._isPointerNearDropContainer = /**
1987
- * Checks whether the pointer coordinates are close to the drop container.
1988
- * @param {?} pointerX Coordinates along the X axis.
1989
- * @param {?} pointerY Coordinates along the Y axis.
1990
- * @return {?}
1991
- */
1992
- function (pointerX, pointerY) {
1993
- var _a = this._positionCache.self, top = _a.top, right = _a.right, bottom = _a.bottom, left = _a.left, width = _a.width, height = _a.height;
1994
- /** @type {?} */
1995
- var xThreshold = width * DROP_PROXIMITY_THRESHOLD;
1996
- /** @type {?} */
1997
- var yThreshold = height * DROP_PROXIMITY_THRESHOLD;
1998
- return pointerY > top - yThreshold && pointerY < bottom + yThreshold &&
1999
- pointerX > left - xThreshold && pointerX < right + xThreshold;
2000
- };
2001
- /**
2002
- * Gets the offset in pixels by which the item that is being dragged should be moved.
2003
- * @param {?} currentPosition Current position of the item.
2004
- * @param {?} newPosition Position of the item where the current item should be moved.
2005
- * @param {?} delta Direction in which the user is moving.
2006
- * @return {?}
2007
- */
2008
- CdkDropList.prototype._getItemOffsetPx = /**
2009
- * Gets the offset in pixels by which the item that is being dragged should be moved.
2010
- * @param {?} currentPosition Current position of the item.
2011
- * @param {?} newPosition Position of the item where the current item should be moved.
2012
- * @param {?} delta Direction in which the user is moving.
2013
- * @return {?}
2014
- */
2015
- function (currentPosition, newPosition, delta) {
2016
- /** @type {?} */
2017
- var isHorizontal = this.orientation === 'horizontal';
2018
- /** @type {?} */
2019
- var itemOffset = isHorizontal ? newPosition.left - currentPosition.left :
2020
- newPosition.top - currentPosition.top;
2021
- // Account for differences in the item width/height.
2022
- if (delta === -1) {
2023
- itemOffset += isHorizontal ? newPosition.width - currentPosition.width :
2024
- newPosition.height - currentPosition.height;
2025
- }
2026
- return itemOffset;
2027
- };
2028
- /**
2029
- * Gets the offset in pixels by which the items that aren't being dragged should be moved.
2030
- * @param {?} currentIndex Index of the item currently being dragged.
2031
- * @param {?} siblings All of the items in the list.
2032
- * @param {?} delta Direction in which the user is moving.
2033
- * @return {?}
2034
- */
2035
- CdkDropList.prototype._getSiblingOffsetPx = /**
2036
- * Gets the offset in pixels by which the items that aren't being dragged should be moved.
2037
- * @param {?} currentIndex Index of the item currently being dragged.
2038
- * @param {?} siblings All of the items in the list.
2039
- * @param {?} delta Direction in which the user is moving.
2040
- * @return {?}
3318
+ * Proxies the events from a DropListRef to events that
3319
+ * match the interfaces of the CdkDropList outputs.
2041
3320
  */
2042
- function (currentIndex, siblings, delta) {
2043
- /** @type {?} */
2044
- var isHorizontal = this.orientation === 'horizontal';
2045
- /** @type {?} */
2046
- var currentPosition = siblings[currentIndex].clientRect;
2047
- /** @type {?} */
2048
- var immediateSibling = siblings[currentIndex + delta * -1];
2049
- /** @type {?} */
2050
- var siblingOffset = currentPosition[isHorizontal ? 'width' : 'height'] * delta;
2051
- if (immediateSibling) {
2052
- /** @type {?} */
2053
- var start = isHorizontal ? 'left' : 'top';
2054
- /** @type {?} */
2055
- var end = isHorizontal ? 'right' : 'bottom';
2056
- // Get the spacing between the start of the current item and the end of the one immediately
2057
- // after it in the direction in which the user is dragging, or vice versa. We add it to the
2058
- // offset in order to push the element to where it will be when it's inline and is influenced
2059
- // by the `margin` of its siblings.
2060
- if (delta === -1) {
2061
- siblingOffset -= immediateSibling.clientRect[start] - currentPosition[end];
2062
- }
2063
- else {
2064
- siblingOffset += currentPosition[start] - immediateSibling.clientRect[end];
2065
- }
2066
- }
2067
- return siblingOffset;
2068
- };
2069
3321
  /**
2070
- * Gets an array of unique drop lists that the current list is connected to.
3322
+ * Proxies the events from a DropListRef to events that
3323
+ * match the interfaces of the CdkDropList outputs.
3324
+ * @private
3325
+ * @param {?} ref
2071
3326
  * @return {?}
2072
3327
  */
2073
- CdkDropList.prototype._getConnectedLists = /**
2074
- * Gets an array of unique drop lists that the current list is connected to.
3328
+ CdkDropList.prototype._proxyEvents = /**
3329
+ * Proxies the events from a DropListRef to events that
3330
+ * match the interfaces of the CdkDropList outputs.
3331
+ * @private
3332
+ * @param {?} ref
2075
3333
  * @return {?}
2076
3334
  */
2077
- function () {
3335
+ function (ref) {
2078
3336
  var _this = this;
2079
- /** @type {?} */
2080
- var siblings = coerceArray(this.connectedTo).map(function (drop) {
2081
- return typeof drop === 'string' ? /** @type {?} */ ((_this._dragDropRegistry.getDropContainer(drop))) : drop;
3337
+ ref.beforeStarted.subscribe(function () {
3338
+ _this._changeDetectorRef.markForCheck();
2082
3339
  });
2083
- if (this._group) {
2084
- this._group._items.forEach(function (drop) {
2085
- if (siblings.indexOf(drop) === -1) {
2086
- siblings.push(drop);
2087
- }
3340
+ ref.entered.subscribe(function (event) {
3341
+ _this.entered.emit({
3342
+ container: _this,
3343
+ item: event.item.data
2088
3344
  });
2089
- }
2090
- return siblings.filter(function (drop) { return drop && drop !== _this; });
3345
+ });
3346
+ ref.exited.subscribe(function (event) {
3347
+ _this.exited.emit({
3348
+ container: _this,
3349
+ item: event.item.data
3350
+ });
3351
+ });
3352
+ ref.sorted.subscribe(function (event) {
3353
+ _this.sorted.emit({
3354
+ previousIndex: event.previousIndex,
3355
+ currentIndex: event.currentIndex,
3356
+ container: _this,
3357
+ item: event.item.data
3358
+ });
3359
+ });
3360
+ ref.dropped.subscribe(function (event) {
3361
+ _this.dropped.emit({
3362
+ previousIndex: event.previousIndex,
3363
+ currentIndex: event.currentIndex,
3364
+ previousContainer: event.previousContainer.data,
3365
+ container: event.container.data,
3366
+ item: event.item.data,
3367
+ isPointerOverContainer: event.isPointerOverContainer
3368
+ });
3369
+ });
2091
3370
  };
3371
+ /**
3372
+ * Keeps track of the drop lists that are currently on the page.
3373
+ */
3374
+ CdkDropList._dropLists = [];
2092
3375
  CdkDropList.decorators = [
2093
3376
  { type: Directive, args: [{
2094
3377
  selector: '[cdkDropList], cdk-drop-list',
2095
3378
  exportAs: 'cdkDropList',
2096
3379
  providers: [
3380
+ // Prevent child drop lists from picking up the same group as their parent.
3381
+ { provide: CdkDropListGroup, useValue: ɵ0 },
2097
3382
  { provide: CDK_DROP_LIST_CONTAINER, useExisting: CdkDropList },
2098
3383
  ],
2099
3384
  host: {
2100
3385
  'class': 'cdk-drop-list',
2101
3386
  '[id]': 'id',
2102
- '[class.cdk-drop-list-dragging]': '_dragging'
3387
+ '[class.cdk-drop-list-dragging]': '_dropListRef.isDragging()',
3388
+ '[class.cdk-drop-list-receiving]': '_dropListRef.isReceiving()',
2103
3389
  }
2104
3390
  },] },
2105
3391
  ];
@@ -2109,7 +3395,8 @@ var CdkDropList = /** @class */ (function () {
2109
3395
  { type: DragDropRegistry },
2110
3396
  { type: ChangeDetectorRef },
2111
3397
  { type: Directionality, decorators: [{ type: Optional }] },
2112
- { type: CdkDropListGroup, decorators: [{ type: Optional }] }
3398
+ { type: CdkDropListGroup, decorators: [{ type: Optional }, { type: SkipSelf }] },
3399
+ { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [DOCUMENT,] }] }
2113
3400
  ]; };
2114
3401
  CdkDropList.propDecorators = {
2115
3402
  _draggables: [{ type: ContentChildren, args: [forwardRef(function () { return CdkDrag; }),] }],
@@ -2118,6 +3405,7 @@ var CdkDropList = /** @class */ (function () {
2118
3405
  orientation: [{ type: Input, args: ['cdkDropListOrientation',] }],
2119
3406
  id: [{ type: Input }],
2120
3407
  lockAxis: [{ type: Input, args: ['cdkDropListLockAxis',] }],
3408
+ disabled: [{ type: Input, args: ['cdkDropListDisabled',] }],
2121
3409
  enterPredicate: [{ type: Input, args: ['cdkDropListEnterPredicate',] }],
2122
3410
  dropped: [{ type: Output, args: ['cdkDropListDropped',] }],
2123
3411
  entered: [{ type: Output, args: ['cdkDropListEntered',] }],
@@ -2126,37 +3414,10 @@ var CdkDropList = /** @class */ (function () {
2126
3414
  };
2127
3415
  return CdkDropList;
2128
3416
  }());
2129
- /**
2130
- * Finds the index of an item that matches a predicate function. Used as an equivalent
2131
- * of `Array.prototype.find` which isn't part of the standard Google typings.
2132
- * @template T
2133
- * @param {?} array Array in which to look for matches.
2134
- * @param {?} predicate Function used to determine whether an item is a match.
2135
- * @return {?}
2136
- */
2137
- function findIndex(array, predicate) {
2138
- for (var i = 0; i < array.length; i++) {
2139
- if (predicate(array[i], i, array)) {
2140
- return i;
2141
- }
2142
- }
2143
- return -1;
2144
- }
2145
- /**
2146
- * Checks whether some coordinates are within a `ClientRect`.
2147
- * @param {?} clientRect ClientRect that is being checked.
2148
- * @param {?} x Coordinates along the X axis.
2149
- * @param {?} y Coordinates along the Y axis.
2150
- * @return {?}
2151
- */
2152
- function isInsideClientRect(clientRect, x, y) {
2153
- var top = clientRect.top, bottom = clientRect.bottom, left = clientRect.left, right = clientRect.right;
2154
- return y >= top && y <= bottom && x >= left && x <= right;
2155
- }
2156
3417
 
2157
3418
  /**
2158
3419
  * @fileoverview added by tsickle
2159
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
3420
+ * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2160
3421
  */
2161
3422
  var DragDropModule = /** @class */ (function () {
2162
3423
  function DragDropModule() {
@@ -2186,13 +3447,13 @@ var DragDropModule = /** @class */ (function () {
2186
3447
 
2187
3448
  /**
2188
3449
  * @fileoverview added by tsickle
2189
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
3450
+ * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2190
3451
  */
2191
3452
 
2192
3453
  /**
2193
3454
  * @fileoverview added by tsickle
2194
- * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
3455
+ * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2195
3456
  */
2196
3457
 
2197
- export { CdkDropList, CdkDropListGroup, CDK_DROP_LIST_CONTAINER, CDK_DRAG_CONFIG_FACTORY, CDK_DRAG_CONFIG, CdkDrag, CdkDragHandle, moveItemInArray, transferArrayItem, copyArrayItem, CdkDragPreview, CdkDragPlaceholder, DragDropModule, DragDropRegistry, CDK_DRAG_PARENT as ɵa };
3458
+ export { CDK_DROP_LIST, CDK_DROP_LIST_CONTAINER, moveItemInArray, transferArrayItem, copyArrayItem, DragDropModule, DragDropRegistry, CdkDropList, CdkDropListGroup, CDK_DRAG_CONFIG_FACTORY, CDK_DRAG_CONFIG, CdkDrag, CdkDragHandle, CdkDragPreview, CdkDragPlaceholder, CDK_DRAG_PARENT as ɵa };
2198
3459
  //# sourceMappingURL=drag-drop.es5.js.map