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