@angular/cdk 10.0.0-rc.3 → 10.1.0

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 (242) hide show
  1. package/a11y/aria-describer/aria-describer.d.ts +10 -1
  2. package/a11y/focus-trap/focus-trap.d.ts +4 -2
  3. package/a11y/index.metadata.json +1 -1
  4. package/a11y/interactivity-checker/interactivity-checker.d.ts +11 -1
  5. package/a11y/key-manager/list-key-manager.d.ts +6 -0
  6. package/accordion/accordion.d.ts +7 -1
  7. package/accordion/index.d.ts +1 -0
  8. package/accordion/index.metadata.json +1 -1
  9. package/bundles/cdk-a11y.umd.js +78 -15
  10. package/bundles/cdk-a11y.umd.js.map +1 -1
  11. package/bundles/cdk-a11y.umd.min.js +11 -11
  12. package/bundles/cdk-a11y.umd.min.js.map +1 -1
  13. package/bundles/cdk-accordion.umd.js +12 -4
  14. package/bundles/cdk-accordion.umd.js.map +1 -1
  15. package/bundles/cdk-accordion.umd.min.js +2 -2
  16. package/bundles/cdk-accordion.umd.min.js.map +1 -1
  17. package/bundles/cdk-drag-drop.umd.js +717 -641
  18. package/bundles/cdk-drag-drop.umd.js.map +1 -1
  19. package/bundles/cdk-drag-drop.umd.min.js +8 -16
  20. package/bundles/cdk-drag-drop.umd.min.js.map +1 -1
  21. package/bundles/cdk-overlay.umd.js +199 -42
  22. package/bundles/cdk-overlay.umd.js.map +1 -1
  23. package/bundles/cdk-overlay.umd.min.js +11 -18
  24. package/bundles/cdk-overlay.umd.min.js.map +1 -1
  25. package/bundles/cdk-platform.umd.js +0 -1
  26. package/bundles/cdk-platform.umd.js.map +1 -1
  27. package/bundles/cdk-platform.umd.min.js +2 -2
  28. package/bundles/cdk-platform.umd.min.js.map +1 -1
  29. package/bundles/cdk-scrolling.umd.js +26 -4
  30. package/bundles/cdk-scrolling.umd.js.map +1 -1
  31. package/bundles/cdk-scrolling.umd.min.js +11 -4
  32. package/bundles/cdk-scrolling.umd.min.js.map +1 -1
  33. package/bundles/cdk-testing-protractor.umd.min.js +1 -1
  34. package/bundles/cdk-testing-protractor.umd.min.js.map +1 -1
  35. package/bundles/cdk-testing-testbed.umd.min.js +8 -8
  36. package/bundles/cdk-testing-testbed.umd.min.js.map +1 -1
  37. package/bundles/cdk-testing.umd.js +32 -0
  38. package/bundles/cdk-testing.umd.js.map +1 -1
  39. package/bundles/cdk-testing.umd.min.js +5 -5
  40. package/bundles/cdk-testing.umd.min.js.map +1 -1
  41. package/bundles/cdk-tree.umd.js +6 -2
  42. package/bundles/cdk-tree.umd.js.map +1 -1
  43. package/bundles/cdk-tree.umd.min.js +3 -3
  44. package/bundles/cdk-tree.umd.min.js.map +1 -1
  45. package/bundles/cdk.umd.js +1 -1
  46. package/bundles/cdk.umd.js.map +1 -1
  47. package/bundles/cdk.umd.min.js +1 -1
  48. package/bundles/cdk.umd.min.js.map +1 -1
  49. package/drag-drop/directives/drag-handle.d.ts +7 -1
  50. package/drag-drop/directives/drag-placeholder.d.ts +7 -1
  51. package/drag-drop/directives/drag-preview.d.ts +7 -1
  52. package/drag-drop/directives/drag.d.ts +4 -14
  53. package/drag-drop/directives/drop-list-group.d.ts +7 -1
  54. package/drag-drop/directives/drop-list.d.ts +7 -1
  55. package/drag-drop/drag-ref.d.ts +6 -0
  56. package/drag-drop/drop-list-ref.d.ts +3 -2
  57. package/drag-drop/index.d.ts +2 -2
  58. package/drag-drop/index.metadata.json +1 -1
  59. package/esm2015/a11y/a11y-module.js +15 -19
  60. package/esm2015/a11y/aria-describer/aria-describer.js +177 -167
  61. package/esm2015/a11y/focus-monitor/focus-monitor.js +337 -345
  62. package/esm2015/a11y/focus-trap/configurable-focus-trap-factory.js +30 -34
  63. package/esm2015/a11y/focus-trap/focus-trap-manager.js +36 -40
  64. package/esm2015/a11y/focus-trap/focus-trap.js +85 -82
  65. package/esm2015/a11y/high-contrast-mode/high-contrast-mode-detector.js +56 -60
  66. package/esm2015/a11y/interactivity-checker/interactivity-checker.js +113 -104
  67. package/esm2015/a11y/key-manager/list-key-manager.js +29 -4
  68. package/esm2015/a11y/live-announcer/live-announcer.js +138 -146
  69. package/esm2015/accordion/accordion-item.js +119 -123
  70. package/esm2015/accordion/accordion-module.js +9 -13
  71. package/esm2015/accordion/accordion.js +49 -46
  72. package/esm2015/accordion/index.js +2 -1
  73. package/esm2015/bidi/bidi-module.js +9 -13
  74. package/esm2015/bidi/dir.js +41 -45
  75. package/esm2015/bidi/directionality.js +27 -31
  76. package/esm2015/clipboard/clipboard-module.js +9 -13
  77. package/esm2015/clipboard/clipboard.js +36 -40
  78. package/esm2015/clipboard/copy-to-clipboard.js +71 -75
  79. package/esm2015/collections/unique-selection-dispatcher.js +33 -37
  80. package/esm2015/drag-drop/directives/drag-handle.js +42 -39
  81. package/esm2015/drag-drop/directives/drag-placeholder.js +24 -21
  82. package/esm2015/drag-drop/directives/drag-preview.js +29 -26
  83. package/esm2015/drag-drop/directives/drag.js +313 -319
  84. package/esm2015/drag-drop/directives/drop-list-group.js +32 -29
  85. package/esm2015/drag-drop/directives/drop-list.js +251 -250
  86. package/esm2015/drag-drop/drag-drop-module.js +27 -31
  87. package/esm2015/drag-drop/drag-drop-registry.js +139 -143
  88. package/esm2015/drag-drop/drag-drop.js +33 -37
  89. package/esm2015/drag-drop/drag-ref.js +59 -25
  90. package/esm2015/drag-drop/drop-list-ref.js +15 -9
  91. package/esm2015/drag-drop/index.js +3 -2
  92. package/esm2015/layout/breakpoints-observer.js +81 -85
  93. package/esm2015/layout/layout-module.js +6 -10
  94. package/esm2015/layout/media-matcher.js +28 -32
  95. package/esm2015/observers/observe-content.js +147 -163
  96. package/esm2015/overlay/dispatchers/base-overlay-dispatcher.js +51 -0
  97. package/esm2015/overlay/dispatchers/index.js +10 -0
  98. package/esm2015/overlay/dispatchers/overlay-keyboard-dispatcher.js +79 -0
  99. package/esm2015/overlay/dispatchers/overlay-outside-click-dispatcher.js +94 -0
  100. package/esm2015/overlay/fullscreen-overlay-container.js +70 -74
  101. package/esm2015/overlay/index.js +5 -4
  102. package/esm2015/overlay/overlay-config.js +5 -1
  103. package/esm2015/overlay/overlay-container.js +69 -73
  104. package/esm2015/overlay/overlay-directives.js +245 -243
  105. package/esm2015/overlay/overlay-module.js +15 -19
  106. package/esm2015/overlay/overlay-ref.js +24 -2
  107. package/esm2015/overlay/overlay-reference.js +1 -1
  108. package/esm2015/overlay/overlay.js +93 -92
  109. package/esm2015/overlay/position/connected-position.js +14 -18
  110. package/esm2015/overlay/position/overlay-position-builder.js +43 -47
  111. package/esm2015/overlay/public-api.js +2 -2
  112. package/esm2015/overlay/scroll/scroll-strategy-options.js +33 -37
  113. package/esm2015/platform/features/scrolling.js +1 -2
  114. package/esm2015/platform/platform-module.js +6 -10
  115. package/esm2015/platform/platform.js +48 -52
  116. package/esm2015/portal/portal-directives.js +181 -201
  117. package/esm2015/scrolling/fixed-size-virtual-scroll.js +57 -47
  118. package/esm2015/scrolling/public-api.js +2 -1
  119. package/esm2015/scrolling/scroll-dispatcher.js +139 -143
  120. package/esm2015/scrolling/scrollable.js +135 -139
  121. package/esm2015/scrolling/scrolling-module.js +32 -40
  122. package/esm2015/scrolling/viewport-ruler.js +105 -109
  123. package/esm2015/scrolling/virtual-for-of.js +264 -268
  124. package/esm2015/scrolling/virtual-scroll-repeater.js +8 -0
  125. package/esm2015/scrolling/virtual-scroll-viewport.js +318 -322
  126. package/esm2015/stepper/step-header.js +20 -24
  127. package/esm2015/stepper/step-label.js +13 -17
  128. package/esm2015/stepper/stepper-button.js +59 -67
  129. package/esm2015/stepper/stepper-module.js +24 -28
  130. package/esm2015/stepper/stepper.js +313 -321
  131. package/esm2015/table/cell.js +129 -157
  132. package/esm2015/table/row.js +183 -219
  133. package/esm2015/table/table-module.js +9 -13
  134. package/esm2015/table/table.js +765 -785
  135. package/esm2015/table/text-column.js +85 -89
  136. package/esm2015/testing/component-harness.js +19 -1
  137. package/esm2015/testing/harness-environment.js +7 -1
  138. package/esm2015/text-field/autofill.js +89 -97
  139. package/esm2015/text-field/autosize.js +225 -229
  140. package/esm2015/text-field/text-field-module.js +10 -14
  141. package/esm2015/tree/control/nested-tree-control.js +7 -3
  142. package/esm2015/tree/nested-node.js +79 -83
  143. package/esm2015/tree/node.js +17 -21
  144. package/esm2015/tree/outlet.js +15 -19
  145. package/esm2015/tree/padding.js +88 -92
  146. package/esm2015/tree/toggle.js +32 -36
  147. package/esm2015/tree/tree-module.js +10 -14
  148. package/esm2015/tree/tree.js +266 -274
  149. package/esm2015/version.js +1 -1
  150. package/fesm2015/a11y.js +1021 -996
  151. package/fesm2015/a11y.js.map +1 -1
  152. package/fesm2015/accordion.js +173 -175
  153. package/fesm2015/accordion.js.map +1 -1
  154. package/fesm2015/bidi.js +74 -83
  155. package/fesm2015/bidi.js.map +1 -1
  156. package/fesm2015/cdk.js +1 -1
  157. package/fesm2015/cdk.js.map +1 -1
  158. package/fesm2015/clipboard.js +113 -122
  159. package/fesm2015/clipboard.js.map +1 -1
  160. package/fesm2015/collections.js +32 -35
  161. package/fesm2015/collections.js.map +1 -1
  162. package/fesm2015/drag-drop.js +1005 -961
  163. package/fesm2015/drag-drop.js.map +1 -1
  164. package/fesm2015/layout.js +111 -120
  165. package/fesm2015/layout.js.map +1 -1
  166. package/fesm2015/observers.js +146 -158
  167. package/fesm2015/observers.js.map +1 -1
  168. package/fesm2015/overlay.js +793 -659
  169. package/fesm2015/overlay.js.map +1 -1
  170. package/fesm2015/platform.js +52 -59
  171. package/fesm2015/platform.js.map +1 -1
  172. package/fesm2015/portal.js +180 -195
  173. package/fesm2015/portal.js.map +1 -1
  174. package/fesm2015/scrolling.js +1058 -1060
  175. package/fesm2015/scrolling.js.map +1 -1
  176. package/fesm2015/stepper.js +424 -445
  177. package/fesm2015/stepper.js.map +1 -1
  178. package/fesm2015/table.js +1178 -1247
  179. package/fesm2015/table.js.map +1 -1
  180. package/fesm2015/testing.js +25 -1
  181. package/fesm2015/testing.js.map +1 -1
  182. package/fesm2015/text-field.js +318 -330
  183. package/fesm2015/text-field.js.map +1 -1
  184. package/fesm2015/tree.js +517 -537
  185. package/fesm2015/tree.js.map +1 -1
  186. package/overlay/dispatchers/base-overlay-dispatcher.d.ts +28 -0
  187. package/overlay/dispatchers/index.d.ts +9 -0
  188. package/overlay/{keyboard → dispatchers}/overlay-keyboard-dispatcher.d.ts +4 -10
  189. package/overlay/dispatchers/overlay-outside-click-dispatcher.d.ts +27 -0
  190. package/overlay/index.d.ts +4 -3
  191. package/overlay/index.metadata.json +1 -1
  192. package/overlay/overlay-config.d.ts +4 -0
  193. package/overlay/overlay-directives.d.ts +4 -0
  194. package/overlay/overlay-ref.d.ts +8 -2
  195. package/overlay/overlay-reference.d.ts +1 -0
  196. package/overlay/overlay.d.ts +4 -2
  197. package/overlay/public-api.d.ts +1 -1
  198. package/package.json +3 -3
  199. package/schematics/index.js +1 -1
  200. package/schematics/migration.json +5 -0
  201. package/schematics/ng-add/index.js +1 -1
  202. package/schematics/ng-update/data/index.js +1 -1
  203. package/schematics/ng-update/devkit-file-system.d.ts +5 -5
  204. package/schematics/ng-update/devkit-file-system.js +21 -16
  205. package/schematics/ng-update/devkit-migration-rule.js +13 -20
  206. package/schematics/ng-update/devkit-migration.d.ts +0 -2
  207. package/schematics/ng-update/devkit-migration.js +1 -1
  208. package/schematics/ng-update/find-stylesheets.d.ts +10 -0
  209. package/schematics/ng-update/find-stylesheets.js +31 -0
  210. package/schematics/ng-update/index.d.ts +2 -0
  211. package/schematics/ng-update/index.js +7 -2
  212. package/schematics/ng-update/migrations/attribute-selectors.js +3 -3
  213. package/schematics/ng-update/migrations/css-selectors.js +3 -3
  214. package/schematics/ng-update/migrations/element-selectors.js +3 -3
  215. package/schematics/ng-update/public-api.js +1 -1
  216. package/schematics/update-tool/component-resource-collector.d.ts +1 -1
  217. package/schematics/update-tool/component-resource-collector.js +18 -14
  218. package/schematics/update-tool/file-system.d.ts +19 -14
  219. package/schematics/update-tool/file-system.js +1 -1
  220. package/schematics/update-tool/index.d.ts +21 -3
  221. package/schematics/update-tool/index.js +29 -23
  222. package/schematics/update-tool/public-api.js +1 -1
  223. package/schematics/update-tool/target-version.d.ts +2 -1
  224. package/schematics/update-tool/target-version.js +5 -3
  225. package/schematics/update-tool/utils/parse-tsconfig.d.ts +2 -1
  226. package/schematics/update-tool/utils/parse-tsconfig.js +6 -10
  227. package/schematics/update-tool/utils/virtual-host.d.ts +34 -0
  228. package/schematics/update-tool/utils/virtual-host.js +62 -0
  229. package/schematics/update-tool/version-changes.js +4 -6
  230. package/schematics/utils/index.js +1 -1
  231. package/schematics/utils/project-tsconfig-paths.d.ts +2 -1
  232. package/schematics/utils/project-tsconfig-paths.js +1 -1
  233. package/scrolling/index.metadata.json +1 -1
  234. package/scrolling/public-api.d.ts +1 -0
  235. package/scrolling/virtual-for-of.d.ts +2 -1
  236. package/scrolling/virtual-scroll-repeater.d.ts +16 -0
  237. package/scrolling/virtual-scroll-viewport.d.ts +4 -4
  238. package/testing/component-harness.d.ts +12 -0
  239. package/testing/harness-environment.d.ts +1 -0
  240. package/tree/control/nested-tree-control.d.ts +7 -2
  241. package/tree/index.metadata.json +1 -1
  242. package/esm2015/overlay/keyboard/overlay-keyboard-dispatcher.js +0 -100
@@ -106,12 +106,26 @@ class FixedSizeVirtualScrollStrategy {
106
106
  if (!this._viewport) {
107
107
  return;
108
108
  }
109
- const scrollOffset = this._viewport.measureScrollOffset();
110
- const firstVisibleIndex = scrollOffset / this._itemSize;
111
109
  const renderedRange = this._viewport.getRenderedRange();
112
110
  const newRange = { start: renderedRange.start, end: renderedRange.end };
113
111
  const viewportSize = this._viewport.getViewportSize();
114
112
  const dataLength = this._viewport.getDataLength();
113
+ let scrollOffset = this._viewport.measureScrollOffset();
114
+ let firstVisibleIndex = scrollOffset / this._itemSize;
115
+ // If user scrolls to the bottom of the list and data changes to a smaller list
116
+ if (newRange.end > dataLength) {
117
+ // We have to recalculate the first visible index based on new data length and viewport size.
118
+ const maxVisibleItems = Math.ceil(viewportSize / this._itemSize);
119
+ const newVisibleIndex = Math.max(0, Math.min(firstVisibleIndex, dataLength - maxVisibleItems));
120
+ // If first visible index changed we must update scroll offset to handle start/end buffers
121
+ // Current range must also be adjusted to cover the new position (bottom of new list).
122
+ if (firstVisibleIndex != newVisibleIndex) {
123
+ firstVisibleIndex = newVisibleIndex;
124
+ scrollOffset = newVisibleIndex * this._itemSize;
125
+ newRange.start = Math.floor(firstVisibleIndex);
126
+ }
127
+ newRange.end = Math.max(0, Math.min(dataLength, newRange.start + maxVisibleItems));
128
+ }
115
129
  const startBuffer = scrollOffset - newRange.start * this._itemSize;
116
130
  if (startBuffer < this._minBufferPx && newRange.start != 0) {
117
131
  const expandStart = Math.ceil((this._maxBufferPx - startBuffer) / this._itemSize);
@@ -143,50 +157,47 @@ function _fixedSizeVirtualScrollStrategyFactory(fixedSizeDir) {
143
157
  return fixedSizeDir._scrollStrategy;
144
158
  }
145
159
  /** A virtual scroll strategy that supports fixed-size items. */
146
- let CdkFixedSizeVirtualScroll = /** @class */ (() => {
147
- class CdkFixedSizeVirtualScroll {
148
- constructor() {
149
- this._itemSize = 20;
150
- this._minBufferPx = 100;
151
- this._maxBufferPx = 200;
152
- /** The scroll strategy used by this directive. */
153
- this._scrollStrategy = new FixedSizeVirtualScrollStrategy(this.itemSize, this.minBufferPx, this.maxBufferPx);
154
- }
155
- /** The size of the items in the list (in pixels). */
156
- get itemSize() { return this._itemSize; }
157
- set itemSize(value) { this._itemSize = coerceNumberProperty(value); }
158
- /**
159
- * The minimum amount of buffer rendered beyond the viewport (in pixels).
160
- * If the amount of buffer dips below this number, more items will be rendered. Defaults to 100px.
161
- */
162
- get minBufferPx() { return this._minBufferPx; }
163
- set minBufferPx(value) { this._minBufferPx = coerceNumberProperty(value); }
164
- /**
165
- * The number of pixels worth of buffer to render for when rendering new items. Defaults to 200px.
166
- */
167
- get maxBufferPx() { return this._maxBufferPx; }
168
- set maxBufferPx(value) { this._maxBufferPx = coerceNumberProperty(value); }
169
- ngOnChanges() {
170
- this._scrollStrategy.updateItemAndBufferSize(this.itemSize, this.minBufferPx, this.maxBufferPx);
171
- }
160
+ class CdkFixedSizeVirtualScroll {
161
+ constructor() {
162
+ this._itemSize = 20;
163
+ this._minBufferPx = 100;
164
+ this._maxBufferPx = 200;
165
+ /** The scroll strategy used by this directive. */
166
+ this._scrollStrategy = new FixedSizeVirtualScrollStrategy(this.itemSize, this.minBufferPx, this.maxBufferPx);
167
+ }
168
+ /** The size of the items in the list (in pixels). */
169
+ get itemSize() { return this._itemSize; }
170
+ set itemSize(value) { this._itemSize = coerceNumberProperty(value); }
171
+ /**
172
+ * The minimum amount of buffer rendered beyond the viewport (in pixels).
173
+ * If the amount of buffer dips below this number, more items will be rendered. Defaults to 100px.
174
+ */
175
+ get minBufferPx() { return this._minBufferPx; }
176
+ set minBufferPx(value) { this._minBufferPx = coerceNumberProperty(value); }
177
+ /**
178
+ * The number of pixels worth of buffer to render for when rendering new items. Defaults to 200px.
179
+ */
180
+ get maxBufferPx() { return this._maxBufferPx; }
181
+ set maxBufferPx(value) { this._maxBufferPx = coerceNumberProperty(value); }
182
+ ngOnChanges() {
183
+ this._scrollStrategy.updateItemAndBufferSize(this.itemSize, this.minBufferPx, this.maxBufferPx);
172
184
  }
173
- CdkFixedSizeVirtualScroll.decorators = [
174
- { type: Directive, args: [{
175
- selector: 'cdk-virtual-scroll-viewport[itemSize]',
176
- providers: [{
177
- provide: VIRTUAL_SCROLL_STRATEGY,
178
- useFactory: _fixedSizeVirtualScrollStrategyFactory,
179
- deps: [forwardRef(() => CdkFixedSizeVirtualScroll)],
180
- }],
181
- },] }
182
- ];
183
- CdkFixedSizeVirtualScroll.propDecorators = {
184
- itemSize: [{ type: Input }],
185
- minBufferPx: [{ type: Input }],
186
- maxBufferPx: [{ type: Input }]
187
- };
188
- return CdkFixedSizeVirtualScroll;
189
- })();
185
+ }
186
+ CdkFixedSizeVirtualScroll.decorators = [
187
+ { type: Directive, args: [{
188
+ selector: 'cdk-virtual-scroll-viewport[itemSize]',
189
+ providers: [{
190
+ provide: VIRTUAL_SCROLL_STRATEGY,
191
+ useFactory: _fixedSizeVirtualScrollStrategyFactory,
192
+ deps: [forwardRef(() => CdkFixedSizeVirtualScroll)],
193
+ }],
194
+ },] }
195
+ ];
196
+ CdkFixedSizeVirtualScroll.propDecorators = {
197
+ itemSize: [{ type: Input }],
198
+ minBufferPx: [{ type: Input }],
199
+ maxBufferPx: [{ type: Input }]
200
+ };
190
201
 
191
202
  /**
192
203
  * @license
@@ -201,156 +212,153 @@ const DEFAULT_SCROLL_TIME = 20;
201
212
  * Service contained all registered Scrollable references and emits an event when any one of the
202
213
  * Scrollable references emit a scrolled event.
203
214
  */
204
- let ScrollDispatcher = /** @class */ (() => {
205
- class ScrollDispatcher {
206
- constructor(_ngZone, _platform,
207
- /** @breaking-change 11.0.0 make document required */
208
- document) {
209
- this._ngZone = _ngZone;
210
- this._platform = _platform;
211
- /** Subject for notifying that a registered scrollable reference element has been scrolled. */
212
- this._scrolled = new Subject();
213
- /** Keeps track of the global `scroll` and `resize` subscriptions. */
214
- this._globalSubscription = null;
215
- /** Keeps track of the amount of subscriptions to `scrolled`. Used for cleaning up afterwards. */
216
- this._scrolledCount = 0;
217
- /**
218
- * Map of all the scrollable references that are registered with the service and their
219
- * scroll event subscriptions.
220
- */
221
- this.scrollContainers = new Map();
222
- this._document = document;
223
- }
224
- /**
225
- * Registers a scrollable instance with the service and listens for its scrolled events. When the
226
- * scrollable is scrolled, the service emits the event to its scrolled observable.
227
- * @param scrollable Scrollable instance to be registered.
228
- */
229
- register(scrollable) {
230
- if (!this.scrollContainers.has(scrollable)) {
231
- this.scrollContainers.set(scrollable, scrollable.elementScrolled()
232
- .subscribe(() => this._scrolled.next(scrollable)));
233
- }
234
- }
215
+ class ScrollDispatcher {
216
+ constructor(_ngZone, _platform,
217
+ /** @breaking-change 11.0.0 make document required */
218
+ document) {
219
+ this._ngZone = _ngZone;
220
+ this._platform = _platform;
221
+ /** Subject for notifying that a registered scrollable reference element has been scrolled. */
222
+ this._scrolled = new Subject();
223
+ /** Keeps track of the global `scroll` and `resize` subscriptions. */
224
+ this._globalSubscription = null;
225
+ /** Keeps track of the amount of subscriptions to `scrolled`. Used for cleaning up afterwards. */
226
+ this._scrolledCount = 0;
235
227
  /**
236
- * Deregisters a Scrollable reference and unsubscribes from its scroll event observable.
237
- * @param scrollable Scrollable instance to be deregistered.
228
+ * Map of all the scrollable references that are registered with the service and their
229
+ * scroll event subscriptions.
238
230
  */
239
- deregister(scrollable) {
240
- const scrollableReference = this.scrollContainers.get(scrollable);
241
- if (scrollableReference) {
242
- scrollableReference.unsubscribe();
243
- this.scrollContainers.delete(scrollable);
244
- }
245
- }
246
- /**
247
- * Returns an observable that emits an event whenever any of the registered Scrollable
248
- * references (or window, document, or body) fire a scrolled event. Can provide a time in ms
249
- * to override the default "throttle" time.
250
- *
251
- * **Note:** in order to avoid hitting change detection for every scroll event,
252
- * all of the events emitted from this stream will be run outside the Angular zone.
253
- * If you need to update any data bindings as a result of a scroll event, you have
254
- * to run the callback using `NgZone.run`.
255
- */
256
- scrolled(auditTimeInMs = DEFAULT_SCROLL_TIME) {
257
- if (!this._platform.isBrowser) {
258
- return of();
259
- }
260
- return new Observable((observer) => {
261
- if (!this._globalSubscription) {
262
- this._addGlobalListener();
263
- }
264
- // In the case of a 0ms delay, use an observable without auditTime
265
- // since it does add a perceptible delay in processing overhead.
266
- const subscription = auditTimeInMs > 0 ?
267
- this._scrolled.pipe(auditTime(auditTimeInMs)).subscribe(observer) :
268
- this._scrolled.subscribe(observer);
269
- this._scrolledCount++;
270
- return () => {
271
- subscription.unsubscribe();
272
- this._scrolledCount--;
273
- if (!this._scrolledCount) {
274
- this._removeGlobalListener();
275
- }
276
- };
277
- });
278
- }
279
- ngOnDestroy() {
280
- this._removeGlobalListener();
281
- this.scrollContainers.forEach((_, container) => this.deregister(container));
282
- this._scrolled.complete();
283
- }
284
- /**
285
- * Returns an observable that emits whenever any of the
286
- * scrollable ancestors of an element are scrolled.
287
- * @param elementRef Element whose ancestors to listen for.
288
- * @param auditTimeInMs Time to throttle the scroll events.
289
- */
290
- ancestorScrolled(elementRef, auditTimeInMs) {
291
- const ancestors = this.getAncestorScrollContainers(elementRef);
292
- return this.scrolled(auditTimeInMs).pipe(filter(target => {
293
- return !target || ancestors.indexOf(target) > -1;
294
- }));
295
- }
296
- /** Returns all registered Scrollables that contain the provided element. */
297
- getAncestorScrollContainers(elementRef) {
298
- const scrollingContainers = [];
299
- this.scrollContainers.forEach((_subscription, scrollable) => {
300
- if (this._scrollableContainsElement(scrollable, elementRef)) {
301
- scrollingContainers.push(scrollable);
302
- }
303
- });
304
- return scrollingContainers;
231
+ this.scrollContainers = new Map();
232
+ this._document = document;
233
+ }
234
+ /**
235
+ * Registers a scrollable instance with the service and listens for its scrolled events. When the
236
+ * scrollable is scrolled, the service emits the event to its scrolled observable.
237
+ * @param scrollable Scrollable instance to be registered.
238
+ */
239
+ register(scrollable) {
240
+ if (!this.scrollContainers.has(scrollable)) {
241
+ this.scrollContainers.set(scrollable, scrollable.elementScrolled()
242
+ .subscribe(() => this._scrolled.next(scrollable)));
305
243
  }
306
- /** Access injected document if available or fallback to global document reference */
307
- _getDocument() {
308
- return this._document || document;
244
+ }
245
+ /**
246
+ * Deregisters a Scrollable reference and unsubscribes from its scroll event observable.
247
+ * @param scrollable Scrollable instance to be deregistered.
248
+ */
249
+ deregister(scrollable) {
250
+ const scrollableReference = this.scrollContainers.get(scrollable);
251
+ if (scrollableReference) {
252
+ scrollableReference.unsubscribe();
253
+ this.scrollContainers.delete(scrollable);
309
254
  }
310
- /** Use defaultView of injected document if available or fallback to global window reference */
311
- _getWindow() {
312
- const doc = this._getDocument();
313
- return doc.defaultView || window;
255
+ }
256
+ /**
257
+ * Returns an observable that emits an event whenever any of the registered Scrollable
258
+ * references (or window, document, or body) fire a scrolled event. Can provide a time in ms
259
+ * to override the default "throttle" time.
260
+ *
261
+ * **Note:** in order to avoid hitting change detection for every scroll event,
262
+ * all of the events emitted from this stream will be run outside the Angular zone.
263
+ * If you need to update any data bindings as a result of a scroll event, you have
264
+ * to run the callback using `NgZone.run`.
265
+ */
266
+ scrolled(auditTimeInMs = DEFAULT_SCROLL_TIME) {
267
+ if (!this._platform.isBrowser) {
268
+ return of();
314
269
  }
315
- /** Returns true if the element is contained within the provided Scrollable. */
316
- _scrollableContainsElement(scrollable, elementRef) {
317
- let element = elementRef.nativeElement;
318
- let scrollableElement = scrollable.getElementRef().nativeElement;
319
- // Traverse through the element parents until we reach null, checking if any of the elements
320
- // are the scrollable's element.
321
- do {
322
- if (element == scrollableElement) {
323
- return true;
270
+ return new Observable((observer) => {
271
+ if (!this._globalSubscription) {
272
+ this._addGlobalListener();
273
+ }
274
+ // In the case of a 0ms delay, use an observable without auditTime
275
+ // since it does add a perceptible delay in processing overhead.
276
+ const subscription = auditTimeInMs > 0 ?
277
+ this._scrolled.pipe(auditTime(auditTimeInMs)).subscribe(observer) :
278
+ this._scrolled.subscribe(observer);
279
+ this._scrolledCount++;
280
+ return () => {
281
+ subscription.unsubscribe();
282
+ this._scrolledCount--;
283
+ if (!this._scrolledCount) {
284
+ this._removeGlobalListener();
324
285
  }
325
- } while (element = element.parentElement);
326
- return false;
327
- }
328
- /** Sets up the global scroll listeners. */
329
- _addGlobalListener() {
330
- this._globalSubscription = this._ngZone.runOutsideAngular(() => {
331
- const window = this._getWindow();
332
- return fromEvent(window.document, 'scroll').subscribe(() => this._scrolled.next());
333
- });
334
- }
335
- /** Cleans up the global scroll listener. */
336
- _removeGlobalListener() {
337
- if (this._globalSubscription) {
338
- this._globalSubscription.unsubscribe();
339
- this._globalSubscription = null;
286
+ };
287
+ });
288
+ }
289
+ ngOnDestroy() {
290
+ this._removeGlobalListener();
291
+ this.scrollContainers.forEach((_, container) => this.deregister(container));
292
+ this._scrolled.complete();
293
+ }
294
+ /**
295
+ * Returns an observable that emits whenever any of the
296
+ * scrollable ancestors of an element are scrolled.
297
+ * @param elementRef Element whose ancestors to listen for.
298
+ * @param auditTimeInMs Time to throttle the scroll events.
299
+ */
300
+ ancestorScrolled(elementRef, auditTimeInMs) {
301
+ const ancestors = this.getAncestorScrollContainers(elementRef);
302
+ return this.scrolled(auditTimeInMs).pipe(filter(target => {
303
+ return !target || ancestors.indexOf(target) > -1;
304
+ }));
305
+ }
306
+ /** Returns all registered Scrollables that contain the provided element. */
307
+ getAncestorScrollContainers(elementRef) {
308
+ const scrollingContainers = [];
309
+ this.scrollContainers.forEach((_subscription, scrollable) => {
310
+ if (this._scrollableContainsElement(scrollable, elementRef)) {
311
+ scrollingContainers.push(scrollable);
312
+ }
313
+ });
314
+ return scrollingContainers;
315
+ }
316
+ /** Access injected document if available or fallback to global document reference */
317
+ _getDocument() {
318
+ return this._document || document;
319
+ }
320
+ /** Use defaultView of injected document if available or fallback to global window reference */
321
+ _getWindow() {
322
+ const doc = this._getDocument();
323
+ return doc.defaultView || window;
324
+ }
325
+ /** Returns true if the element is contained within the provided Scrollable. */
326
+ _scrollableContainsElement(scrollable, elementRef) {
327
+ let element = elementRef.nativeElement;
328
+ let scrollableElement = scrollable.getElementRef().nativeElement;
329
+ // Traverse through the element parents until we reach null, checking if any of the elements
330
+ // are the scrollable's element.
331
+ do {
332
+ if (element == scrollableElement) {
333
+ return true;
340
334
  }
335
+ } while (element = element.parentElement);
336
+ return false;
337
+ }
338
+ /** Sets up the global scroll listeners. */
339
+ _addGlobalListener() {
340
+ this._globalSubscription = this._ngZone.runOutsideAngular(() => {
341
+ const window = this._getWindow();
342
+ return fromEvent(window.document, 'scroll').subscribe(() => this._scrolled.next());
343
+ });
344
+ }
345
+ /** Cleans up the global scroll listener. */
346
+ _removeGlobalListener() {
347
+ if (this._globalSubscription) {
348
+ this._globalSubscription.unsubscribe();
349
+ this._globalSubscription = null;
341
350
  }
342
351
  }
343
- ScrollDispatcher.ɵprov = ɵɵdefineInjectable({ factory: function ScrollDispatcher_Factory() { return new ScrollDispatcher(ɵɵinject(NgZone), ɵɵinject(Platform), ɵɵinject(DOCUMENT, 8)); }, token: ScrollDispatcher, providedIn: "root" });
344
- ScrollDispatcher.decorators = [
345
- { type: Injectable, args: [{ providedIn: 'root' },] }
346
- ];
347
- ScrollDispatcher.ctorParameters = () => [
348
- { type: NgZone },
349
- { type: Platform },
350
- { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [DOCUMENT,] }] }
351
- ];
352
- return ScrollDispatcher;
353
- })();
352
+ }
353
+ ScrollDispatcher.ɵprov = ɵɵdefineInjectable({ factory: function ScrollDispatcher_Factory() { return new ScrollDispatcher(ɵɵinject(NgZone), ɵɵinject(Platform), ɵɵinject(DOCUMENT, 8)); }, token: ScrollDispatcher, providedIn: "root" });
354
+ ScrollDispatcher.decorators = [
355
+ { type: Injectable, args: [{ providedIn: 'root' },] }
356
+ ];
357
+ ScrollDispatcher.ctorParameters = () => [
358
+ { type: NgZone },
359
+ { type: Platform },
360
+ { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [DOCUMENT,] }] }
361
+ ];
354
362
 
355
363
  /**
356
364
  * @license
@@ -364,163 +372,160 @@ let ScrollDispatcher = /** @class */ (() => {
364
372
  * ScrollDispatcher service to include itself as part of its collection of scrolling events that it
365
373
  * can be listened to through the service.
366
374
  */
367
- let CdkScrollable = /** @class */ (() => {
368
- class CdkScrollable {
369
- constructor(elementRef, scrollDispatcher, ngZone, dir) {
370
- this.elementRef = elementRef;
371
- this.scrollDispatcher = scrollDispatcher;
372
- this.ngZone = ngZone;
373
- this.dir = dir;
374
- this._destroyed = new Subject();
375
- this._elementScrolled = new Observable((observer) => this.ngZone.runOutsideAngular(() => fromEvent(this.elementRef.nativeElement, 'scroll').pipe(takeUntil(this._destroyed))
376
- .subscribe(observer)));
377
- }
378
- ngOnInit() {
379
- this.scrollDispatcher.register(this);
380
- }
381
- ngOnDestroy() {
382
- this.scrollDispatcher.deregister(this);
383
- this._destroyed.next();
384
- this._destroyed.complete();
375
+ class CdkScrollable {
376
+ constructor(elementRef, scrollDispatcher, ngZone, dir) {
377
+ this.elementRef = elementRef;
378
+ this.scrollDispatcher = scrollDispatcher;
379
+ this.ngZone = ngZone;
380
+ this.dir = dir;
381
+ this._destroyed = new Subject();
382
+ this._elementScrolled = new Observable((observer) => this.ngZone.runOutsideAngular(() => fromEvent(this.elementRef.nativeElement, 'scroll').pipe(takeUntil(this._destroyed))
383
+ .subscribe(observer)));
384
+ }
385
+ ngOnInit() {
386
+ this.scrollDispatcher.register(this);
387
+ }
388
+ ngOnDestroy() {
389
+ this.scrollDispatcher.deregister(this);
390
+ this._destroyed.next();
391
+ this._destroyed.complete();
392
+ }
393
+ /** Returns observable that emits when a scroll event is fired on the host element. */
394
+ elementScrolled() {
395
+ return this._elementScrolled;
396
+ }
397
+ /** Gets the ElementRef for the viewport. */
398
+ getElementRef() {
399
+ return this.elementRef;
400
+ }
401
+ /**
402
+ * Scrolls to the specified offsets. This is a normalized version of the browser's native scrollTo
403
+ * method, since browsers are not consistent about what scrollLeft means in RTL. For this method
404
+ * left and right always refer to the left and right side of the scrolling container irrespective
405
+ * of the layout direction. start and end refer to left and right in an LTR context and vice-versa
406
+ * in an RTL context.
407
+ * @param options specified the offsets to scroll to.
408
+ */
409
+ scrollTo(options) {
410
+ const el = this.elementRef.nativeElement;
411
+ const isRtl = this.dir && this.dir.value == 'rtl';
412
+ // Rewrite start & end offsets as right or left offsets.
413
+ if (options.left == null) {
414
+ options.left = isRtl ? options.end : options.start;
415
+ }
416
+ if (options.right == null) {
417
+ options.right = isRtl ? options.start : options.end;
418
+ }
419
+ // Rewrite the bottom offset as a top offset.
420
+ if (options.bottom != null) {
421
+ options.top =
422
+ el.scrollHeight - el.clientHeight - options.bottom;
423
+ }
424
+ // Rewrite the right offset as a left offset.
425
+ if (isRtl && getRtlScrollAxisType() != 0 /* NORMAL */) {
426
+ if (options.left != null) {
427
+ options.right =
428
+ el.scrollWidth - el.clientWidth - options.left;
429
+ }
430
+ if (getRtlScrollAxisType() == 2 /* INVERTED */) {
431
+ options.left = options.right;
432
+ }
433
+ else if (getRtlScrollAxisType() == 1 /* NEGATED */) {
434
+ options.left = options.right ? -options.right : options.right;
435
+ }
385
436
  }
386
- /** Returns observable that emits when a scroll event is fired on the host element. */
387
- elementScrolled() {
388
- return this._elementScrolled;
437
+ else {
438
+ if (options.right != null) {
439
+ options.left =
440
+ el.scrollWidth - el.clientWidth - options.right;
441
+ }
389
442
  }
390
- /** Gets the ElementRef for the viewport. */
391
- getElementRef() {
392
- return this.elementRef;
443
+ this._applyScrollToOptions(options);
444
+ }
445
+ _applyScrollToOptions(options) {
446
+ const el = this.elementRef.nativeElement;
447
+ if (supportsScrollBehavior()) {
448
+ el.scrollTo(options);
393
449
  }
394
- /**
395
- * Scrolls to the specified offsets. This is a normalized version of the browser's native scrollTo
396
- * method, since browsers are not consistent about what scrollLeft means in RTL. For this method
397
- * left and right always refer to the left and right side of the scrolling container irrespective
398
- * of the layout direction. start and end refer to left and right in an LTR context and vice-versa
399
- * in an RTL context.
400
- * @param options specified the offsets to scroll to.
401
- */
402
- scrollTo(options) {
403
- const el = this.elementRef.nativeElement;
404
- const isRtl = this.dir && this.dir.value == 'rtl';
405
- // Rewrite start & end offsets as right or left offsets.
406
- if (options.left == null) {
407
- options.left = isRtl ? options.end : options.start;
408
- }
409
- if (options.right == null) {
410
- options.right = isRtl ? options.start : options.end;
450
+ else {
451
+ if (options.top != null) {
452
+ el.scrollTop = options.top;
411
453
  }
412
- // Rewrite the bottom offset as a top offset.
413
- if (options.bottom != null) {
414
- options.top =
415
- el.scrollHeight - el.clientHeight - options.bottom;
454
+ if (options.left != null) {
455
+ el.scrollLeft = options.left;
416
456
  }
417
- // Rewrite the right offset as a left offset.
418
- if (isRtl && getRtlScrollAxisType() != 0 /* NORMAL */) {
419
- if (options.left != null) {
420
- options.right =
421
- el.scrollWidth - el.clientWidth - options.left;
422
- }
423
- if (getRtlScrollAxisType() == 2 /* INVERTED */) {
424
- options.left = options.right;
425
- }
426
- else if (getRtlScrollAxisType() == 1 /* NEGATED */) {
427
- options.left = options.right ? -options.right : options.right;
428
- }
457
+ }
458
+ }
459
+ /**
460
+ * Measures the scroll offset relative to the specified edge of the viewport. This method can be
461
+ * used instead of directly checking scrollLeft or scrollTop, since browsers are not consistent
462
+ * about what scrollLeft means in RTL. The values returned by this method are normalized such that
463
+ * left and right always refer to the left and right side of the scrolling container irrespective
464
+ * of the layout direction. start and end refer to left and right in an LTR context and vice-versa
465
+ * in an RTL context.
466
+ * @param from The edge to measure from.
467
+ */
468
+ measureScrollOffset(from) {
469
+ const LEFT = 'left';
470
+ const RIGHT = 'right';
471
+ const el = this.elementRef.nativeElement;
472
+ if (from == 'top') {
473
+ return el.scrollTop;
474
+ }
475
+ if (from == 'bottom') {
476
+ return el.scrollHeight - el.clientHeight - el.scrollTop;
477
+ }
478
+ // Rewrite start & end as left or right offsets.
479
+ const isRtl = this.dir && this.dir.value == 'rtl';
480
+ if (from == 'start') {
481
+ from = isRtl ? RIGHT : LEFT;
482
+ }
483
+ else if (from == 'end') {
484
+ from = isRtl ? LEFT : RIGHT;
485
+ }
486
+ if (isRtl && getRtlScrollAxisType() == 2 /* INVERTED */) {
487
+ // For INVERTED, scrollLeft is (scrollWidth - clientWidth) when scrolled all the way left and
488
+ // 0 when scrolled all the way right.
489
+ if (from == LEFT) {
490
+ return el.scrollWidth - el.clientWidth - el.scrollLeft;
429
491
  }
430
492
  else {
431
- if (options.right != null) {
432
- options.left =
433
- el.scrollWidth - el.clientWidth - options.right;
434
- }
493
+ return el.scrollLeft;
435
494
  }
436
- this._applyScrollToOptions(options);
437
495
  }
438
- _applyScrollToOptions(options) {
439
- const el = this.elementRef.nativeElement;
440
- if (supportsScrollBehavior()) {
441
- el.scrollTo(options);
496
+ else if (isRtl && getRtlScrollAxisType() == 1 /* NEGATED */) {
497
+ // For NEGATED, scrollLeft is -(scrollWidth - clientWidth) when scrolled all the way left and
498
+ // 0 when scrolled all the way right.
499
+ if (from == LEFT) {
500
+ return el.scrollLeft + el.scrollWidth - el.clientWidth;
442
501
  }
443
502
  else {
444
- if (options.top != null) {
445
- el.scrollTop = options.top;
446
- }
447
- if (options.left != null) {
448
- el.scrollLeft = options.left;
449
- }
503
+ return -el.scrollLeft;
450
504
  }
451
505
  }
452
- /**
453
- * Measures the scroll offset relative to the specified edge of the viewport. This method can be
454
- * used instead of directly checking scrollLeft or scrollTop, since browsers are not consistent
455
- * about what scrollLeft means in RTL. The values returned by this method are normalized such that
456
- * left and right always refer to the left and right side of the scrolling container irrespective
457
- * of the layout direction. start and end refer to left and right in an LTR context and vice-versa
458
- * in an RTL context.
459
- * @param from The edge to measure from.
460
- */
461
- measureScrollOffset(from) {
462
- const LEFT = 'left';
463
- const RIGHT = 'right';
464
- const el = this.elementRef.nativeElement;
465
- if (from == 'top') {
466
- return el.scrollTop;
467
- }
468
- if (from == 'bottom') {
469
- return el.scrollHeight - el.clientHeight - el.scrollTop;
470
- }
471
- // Rewrite start & end as left or right offsets.
472
- const isRtl = this.dir && this.dir.value == 'rtl';
473
- if (from == 'start') {
474
- from = isRtl ? RIGHT : LEFT;
475
- }
476
- else if (from == 'end') {
477
- from = isRtl ? LEFT : RIGHT;
478
- }
479
- if (isRtl && getRtlScrollAxisType() == 2 /* INVERTED */) {
480
- // For INVERTED, scrollLeft is (scrollWidth - clientWidth) when scrolled all the way left and
481
- // 0 when scrolled all the way right.
482
- if (from == LEFT) {
483
- return el.scrollWidth - el.clientWidth - el.scrollLeft;
484
- }
485
- else {
486
- return el.scrollLeft;
487
- }
488
- }
489
- else if (isRtl && getRtlScrollAxisType() == 1 /* NEGATED */) {
490
- // For NEGATED, scrollLeft is -(scrollWidth - clientWidth) when scrolled all the way left and
491
- // 0 when scrolled all the way right.
492
- if (from == LEFT) {
493
- return el.scrollLeft + el.scrollWidth - el.clientWidth;
494
- }
495
- else {
496
- return -el.scrollLeft;
497
- }
506
+ else {
507
+ // For NORMAL, as well as non-RTL contexts, scrollLeft is 0 when scrolled all the way left and
508
+ // (scrollWidth - clientWidth) when scrolled all the way right.
509
+ if (from == LEFT) {
510
+ return el.scrollLeft;
498
511
  }
499
512
  else {
500
- // For NORMAL, as well as non-RTL contexts, scrollLeft is 0 when scrolled all the way left and
501
- // (scrollWidth - clientWidth) when scrolled all the way right.
502
- if (from == LEFT) {
503
- return el.scrollLeft;
504
- }
505
- else {
506
- return el.scrollWidth - el.clientWidth - el.scrollLeft;
507
- }
513
+ return el.scrollWidth - el.clientWidth - el.scrollLeft;
508
514
  }
509
515
  }
510
516
  }
511
- CdkScrollable.decorators = [
512
- { type: Directive, args: [{
513
- selector: '[cdk-scrollable], [cdkScrollable]'
514
- },] }
515
- ];
516
- CdkScrollable.ctorParameters = () => [
517
- { type: ElementRef },
518
- { type: ScrollDispatcher },
519
- { type: NgZone },
520
- { type: Directionality, decorators: [{ type: Optional }] }
521
- ];
522
- return CdkScrollable;
523
- })();
517
+ }
518
+ CdkScrollable.decorators = [
519
+ { type: Directive, args: [{
520
+ selector: '[cdk-scrollable], [cdkScrollable]'
521
+ },] }
522
+ ];
523
+ CdkScrollable.ctorParameters = () => [
524
+ { type: ElementRef },
525
+ { type: ScrollDispatcher },
526
+ { type: NgZone },
527
+ { type: Directionality, decorators: [{ type: Optional }] }
528
+ ];
524
529
 
525
530
  /**
526
531
  * @license
@@ -535,118 +540,115 @@ const DEFAULT_RESIZE_TIME = 20;
535
540
  * Simple utility for getting the bounds of the browser viewport.
536
541
  * @docs-private
537
542
  */
538
- let ViewportRuler = /** @class */ (() => {
539
- class ViewportRuler {
540
- constructor(_platform, ngZone,
541
- /** @breaking-change 11.0.0 make document required */
542
- document) {
543
- this._platform = _platform;
544
- this._document = document;
545
- ngZone.runOutsideAngular(() => {
546
- const window = this._getWindow();
547
- this._change = _platform.isBrowser ?
548
- merge(fromEvent(window, 'resize'), fromEvent(window, 'orientationchange')) :
549
- of();
550
- // Note that we need to do the subscription inside `runOutsideAngular`
551
- // since subscribing is what causes the event listener to be added.
552
- this._invalidateCache = this.change().subscribe(() => this._updateViewportSize());
553
- });
554
- }
555
- ngOnDestroy() {
556
- this._invalidateCache.unsubscribe();
557
- }
558
- /** Returns the viewport's width and height. */
559
- getViewportSize() {
560
- if (!this._viewportSize) {
561
- this._updateViewportSize();
562
- }
563
- const output = { width: this._viewportSize.width, height: this._viewportSize.height };
564
- // If we're not on a browser, don't cache the size since it'll be mocked out anyway.
565
- if (!this._platform.isBrowser) {
566
- this._viewportSize = null;
567
- }
568
- return output;
569
- }
570
- /** Gets a ClientRect for the viewport's bounds. */
571
- getViewportRect() {
572
- // Use the document element's bounding rect rather than the window scroll properties
573
- // (e.g. pageYOffset, scrollY) due to in issue in Chrome and IE where window scroll
574
- // properties and client coordinates (boundingClientRect, clientX/Y, etc.) are in different
575
- // conceptual viewports. Under most circumstances these viewports are equivalent, but they
576
- // can disagree when the page is pinch-zoomed (on devices that support touch).
577
- // See https://bugs.chromium.org/p/chromium/issues/detail?id=489206#c4
578
- // We use the documentElement instead of the body because, by default (without a css reset)
579
- // browsers typically give the document body an 8px margin, which is not included in
580
- // getBoundingClientRect().
581
- const scrollPosition = this.getViewportScrollPosition();
582
- const { width, height } = this.getViewportSize();
583
- return {
584
- top: scrollPosition.top,
585
- left: scrollPosition.left,
586
- bottom: scrollPosition.top + height,
587
- right: scrollPosition.left + width,
588
- height,
589
- width,
590
- };
591
- }
592
- /** Gets the (top, left) scroll position of the viewport. */
593
- getViewportScrollPosition() {
594
- // While we can get a reference to the fake document
595
- // during SSR, it doesn't have getBoundingClientRect.
596
- if (!this._platform.isBrowser) {
597
- return { top: 0, left: 0 };
598
- }
599
- // The top-left-corner of the viewport is determined by the scroll position of the document
600
- // body, normally just (scrollLeft, scrollTop). However, Chrome and Firefox disagree about
601
- // whether `document.body` or `document.documentElement` is the scrolled element, so reading
602
- // `scrollTop` and `scrollLeft` is inconsistent. However, using the bounding rect of
603
- // `document.documentElement` works consistently, where the `top` and `left` values will
604
- // equal negative the scroll position.
605
- const document = this._getDocument();
543
+ class ViewportRuler {
544
+ constructor(_platform, ngZone,
545
+ /** @breaking-change 11.0.0 make document required */
546
+ document) {
547
+ this._platform = _platform;
548
+ this._document = document;
549
+ ngZone.runOutsideAngular(() => {
606
550
  const window = this._getWindow();
607
- const documentElement = document.documentElement;
608
- const documentRect = documentElement.getBoundingClientRect();
609
- const top = -documentRect.top || document.body.scrollTop || window.scrollY ||
610
- documentElement.scrollTop || 0;
611
- const left = -documentRect.left || document.body.scrollLeft || window.scrollX ||
612
- documentElement.scrollLeft || 0;
613
- return { top, left };
614
- }
615
- /**
616
- * Returns a stream that emits whenever the size of the viewport changes.
617
- * @param throttleTime Time in milliseconds to throttle the stream.
618
- */
619
- change(throttleTime = DEFAULT_RESIZE_TIME) {
620
- return throttleTime > 0 ? this._change.pipe(auditTime(throttleTime)) : this._change;
621
- }
622
- /** Access injected document if available or fallback to global document reference */
623
- _getDocument() {
624
- return this._document || document;
625
- }
626
- /** Use defaultView of injected document if available or fallback to global window reference */
627
- _getWindow() {
628
- const doc = this._getDocument();
629
- return doc.defaultView || window;
551
+ this._change = _platform.isBrowser ?
552
+ merge(fromEvent(window, 'resize'), fromEvent(window, 'orientationchange')) :
553
+ of();
554
+ // Note that we need to do the subscription inside `runOutsideAngular`
555
+ // since subscribing is what causes the event listener to be added.
556
+ this._invalidateCache = this.change().subscribe(() => this._updateViewportSize());
557
+ });
558
+ }
559
+ ngOnDestroy() {
560
+ this._invalidateCache.unsubscribe();
561
+ }
562
+ /** Returns the viewport's width and height. */
563
+ getViewportSize() {
564
+ if (!this._viewportSize) {
565
+ this._updateViewportSize();
630
566
  }
631
- /** Updates the cached viewport size. */
632
- _updateViewportSize() {
633
- const window = this._getWindow();
634
- this._viewportSize = this._platform.isBrowser ?
635
- { width: window.innerWidth, height: window.innerHeight } :
636
- { width: 0, height: 0 };
567
+ const output = { width: this._viewportSize.width, height: this._viewportSize.height };
568
+ // If we're not on a browser, don't cache the size since it'll be mocked out anyway.
569
+ if (!this._platform.isBrowser) {
570
+ this._viewportSize = null;
637
571
  }
572
+ return output;
573
+ }
574
+ /** Gets a ClientRect for the viewport's bounds. */
575
+ getViewportRect() {
576
+ // Use the document element's bounding rect rather than the window scroll properties
577
+ // (e.g. pageYOffset, scrollY) due to in issue in Chrome and IE where window scroll
578
+ // properties and client coordinates (boundingClientRect, clientX/Y, etc.) are in different
579
+ // conceptual viewports. Under most circumstances these viewports are equivalent, but they
580
+ // can disagree when the page is pinch-zoomed (on devices that support touch).
581
+ // See https://bugs.chromium.org/p/chromium/issues/detail?id=489206#c4
582
+ // We use the documentElement instead of the body because, by default (without a css reset)
583
+ // browsers typically give the document body an 8px margin, which is not included in
584
+ // getBoundingClientRect().
585
+ const scrollPosition = this.getViewportScrollPosition();
586
+ const { width, height } = this.getViewportSize();
587
+ return {
588
+ top: scrollPosition.top,
589
+ left: scrollPosition.left,
590
+ bottom: scrollPosition.top + height,
591
+ right: scrollPosition.left + width,
592
+ height,
593
+ width,
594
+ };
595
+ }
596
+ /** Gets the (top, left) scroll position of the viewport. */
597
+ getViewportScrollPosition() {
598
+ // While we can get a reference to the fake document
599
+ // during SSR, it doesn't have getBoundingClientRect.
600
+ if (!this._platform.isBrowser) {
601
+ return { top: 0, left: 0 };
602
+ }
603
+ // The top-left-corner of the viewport is determined by the scroll position of the document
604
+ // body, normally just (scrollLeft, scrollTop). However, Chrome and Firefox disagree about
605
+ // whether `document.body` or `document.documentElement` is the scrolled element, so reading
606
+ // `scrollTop` and `scrollLeft` is inconsistent. However, using the bounding rect of
607
+ // `document.documentElement` works consistently, where the `top` and `left` values will
608
+ // equal negative the scroll position.
609
+ const document = this._getDocument();
610
+ const window = this._getWindow();
611
+ const documentElement = document.documentElement;
612
+ const documentRect = documentElement.getBoundingClientRect();
613
+ const top = -documentRect.top || document.body.scrollTop || window.scrollY ||
614
+ documentElement.scrollTop || 0;
615
+ const left = -documentRect.left || document.body.scrollLeft || window.scrollX ||
616
+ documentElement.scrollLeft || 0;
617
+ return { top, left };
618
+ }
619
+ /**
620
+ * Returns a stream that emits whenever the size of the viewport changes.
621
+ * @param throttleTime Time in milliseconds to throttle the stream.
622
+ */
623
+ change(throttleTime = DEFAULT_RESIZE_TIME) {
624
+ return throttleTime > 0 ? this._change.pipe(auditTime(throttleTime)) : this._change;
625
+ }
626
+ /** Access injected document if available or fallback to global document reference */
627
+ _getDocument() {
628
+ return this._document || document;
629
+ }
630
+ /** Use defaultView of injected document if available or fallback to global window reference */
631
+ _getWindow() {
632
+ const doc = this._getDocument();
633
+ return doc.defaultView || window;
634
+ }
635
+ /** Updates the cached viewport size. */
636
+ _updateViewportSize() {
637
+ const window = this._getWindow();
638
+ this._viewportSize = this._platform.isBrowser ?
639
+ { width: window.innerWidth, height: window.innerHeight } :
640
+ { width: 0, height: 0 };
638
641
  }
639
- ViewportRuler.ɵprov = ɵɵdefineInjectable({ factory: function ViewportRuler_Factory() { return new ViewportRuler(ɵɵinject(Platform), ɵɵinject(NgZone), ɵɵinject(DOCUMENT, 8)); }, token: ViewportRuler, providedIn: "root" });
640
- ViewportRuler.decorators = [
641
- { type: Injectable, args: [{ providedIn: 'root' },] }
642
- ];
643
- ViewportRuler.ctorParameters = () => [
644
- { type: Platform },
645
- { type: NgZone },
646
- { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [DOCUMENT,] }] }
647
- ];
648
- return ViewportRuler;
649
- })();
642
+ }
643
+ ViewportRuler.ɵprov = ɵɵdefineInjectable({ factory: function ViewportRuler_Factory() { return new ViewportRuler(ɵɵinject(Platform), ɵɵinject(NgZone), ɵɵinject(DOCUMENT, 8)); }, token: ViewportRuler, providedIn: "root" });
644
+ ViewportRuler.decorators = [
645
+ { type: Injectable, args: [{ providedIn: 'root' },] }
646
+ ];
647
+ ViewportRuler.ctorParameters = () => [
648
+ { type: Platform },
649
+ { type: NgZone },
650
+ { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [DOCUMENT,] }] }
651
+ ];
650
652
 
651
653
  /**
652
654
  * @license
@@ -666,345 +668,342 @@ function rangesEqual(r1, r2) {
666
668
  */
667
669
  const SCROLL_SCHEDULER = typeof requestAnimationFrame !== 'undefined' ? animationFrameScheduler : asapScheduler;
668
670
  /** A viewport that virtualizes its scrolling with the help of `CdkVirtualForOf`. */
669
- let CdkVirtualScrollViewport = /** @class */ (() => {
670
- class CdkVirtualScrollViewport extends CdkScrollable {
671
- constructor(elementRef, _changeDetectorRef, ngZone, _scrollStrategy, dir, scrollDispatcher,
672
- /**
673
- * @deprecated `viewportRuler` parameter to become required.
674
- * @breaking-change 11.0.0
675
- */
676
- viewportRuler) {
677
- super(elementRef, scrollDispatcher, ngZone, dir);
678
- this.elementRef = elementRef;
679
- this._changeDetectorRef = _changeDetectorRef;
680
- this._scrollStrategy = _scrollStrategy;
681
- /** Emits when the viewport is detached from a CdkVirtualForOf. */
682
- this._detachedSubject = new Subject();
683
- /** Emits when the rendered range changes. */
684
- this._renderedRangeSubject = new Subject();
685
- this._orientation = 'vertical';
686
- // Note: we don't use the typical EventEmitter here because we need to subscribe to the scroll
687
- // strategy lazily (i.e. only if the user is actually listening to the events). We do this because
688
- // depending on how the strategy calculates the scrolled index, it may come at a cost to
689
- // performance.
690
- /** Emits when the index of the first element visible in the viewport changes. */
691
- this.scrolledIndexChange = new Observable((observer) => this._scrollStrategy.scrolledIndexChange.subscribe(index => Promise.resolve().then(() => this.ngZone.run(() => observer.next(index)))));
692
- /** A stream that emits whenever the rendered range changes. */
693
- this.renderedRangeStream = this._renderedRangeSubject.asObservable();
694
- /**
695
- * The total size of all content (in pixels), including content that is not currently rendered.
696
- */
697
- this._totalContentSize = 0;
698
- /** A string representing the `style.width` property value to be used for the spacer element. */
699
- this._totalContentWidth = '';
700
- /** A string representing the `style.height` property value to be used for the spacer element. */
701
- this._totalContentHeight = '';
702
- /** The currently rendered range of indices. */
703
- this._renderedRange = { start: 0, end: 0 };
704
- /** The length of the data bound to this viewport (in number of items). */
705
- this._dataLength = 0;
706
- /** The size of the viewport (in pixels). */
707
- this._viewportSize = 0;
708
- /** The last rendered content offset that was set. */
709
- this._renderedContentOffset = 0;
710
- /**
711
- * Whether the last rendered content offset was to the end of the content (and therefore needs to
712
- * be rewritten as an offset to the start of the content).
713
- */
714
- this._renderedContentOffsetNeedsRewrite = false;
715
- /** Whether there is a pending change detection cycle. */
716
- this._isChangeDetectionPending = false;
717
- /** A list of functions to run after the next change detection cycle. */
718
- this._runAfterChangeDetection = [];
719
- /** Subscription to changes in the viewport size. */
720
- this._viewportChanges = Subscription.EMPTY;
721
- if (!_scrollStrategy) {
722
- throw Error('Error: cdk-virtual-scroll-viewport requires the "itemSize" property to be set.');
723
- }
724
- // @breaking-change 11.0.0 Remove null check for `viewportRuler`.
725
- if (viewportRuler) {
726
- this._viewportChanges = viewportRuler.change().subscribe(() => {
727
- this.checkViewportSize();
728
- });
729
- }
730
- }
731
- /** The direction the viewport scrolls. */
732
- get orientation() {
733
- return this._orientation;
734
- }
735
- set orientation(orientation) {
736
- if (this._orientation !== orientation) {
737
- this._orientation = orientation;
738
- this._calculateSpacerSize();
739
- }
740
- }
741
- ngOnInit() {
742
- super.ngOnInit();
743
- // It's still too early to measure the viewport at this point. Deferring with a promise allows
744
- // the Viewport to be rendered with the correct size before we measure. We run this outside the
745
- // zone to avoid causing more change detection cycles. We handle the change detection loop
746
- // ourselves instead.
747
- this.ngZone.runOutsideAngular(() => Promise.resolve().then(() => {
748
- this._measureViewportSize();
749
- this._scrollStrategy.attach(this);
750
- this.elementScrolled()
751
- .pipe(
752
- // Start off with a fake scroll event so we properly detect our initial position.
753
- startWith(null),
754
- // Collect multiple events into one until the next animation frame. This way if
755
- // there are multiple scroll events in the same frame we only need to recheck
756
- // our layout once.
757
- auditTime(0, SCROLL_SCHEDULER))
758
- .subscribe(() => this._scrollStrategy.onContentScrolled());
759
- this._markChangeDetectionNeeded();
760
- }));
761
- }
762
- ngOnDestroy() {
763
- this.detach();
764
- this._scrollStrategy.detach();
765
- // Complete all subjects
766
- this._renderedRangeSubject.complete();
767
- this._detachedSubject.complete();
768
- this._viewportChanges.unsubscribe();
769
- super.ngOnDestroy();
770
- }
771
- /** Attaches a `CdkVirtualForOf` to this viewport. */
772
- attach(forOf) {
773
- if (this._forOf) {
774
- throw Error('CdkVirtualScrollViewport is already attached.');
775
- }
776
- // Subscribe to the data stream of the CdkVirtualForOf to keep track of when the data length
777
- // changes. Run outside the zone to avoid triggering change detection, since we're managing the
778
- // change detection loop ourselves.
779
- this.ngZone.runOutsideAngular(() => {
780
- this._forOf = forOf;
781
- this._forOf.dataStream.pipe(takeUntil(this._detachedSubject)).subscribe(data => {
782
- const newLength = data.length;
783
- if (newLength !== this._dataLength) {
784
- this._dataLength = newLength;
785
- this._scrollStrategy.onDataLengthChanged();
786
- }
787
- this._doChangeDetection();
788
- });
789
- });
790
- }
791
- /** Detaches the current `CdkVirtualForOf`. */
792
- detach() {
793
- this._forOf = null;
794
- this._detachedSubject.next();
795
- }
796
- /** Gets the length of the data bound to this viewport (in number of items). */
797
- getDataLength() {
798
- return this._dataLength;
799
- }
800
- /** Gets the size of the viewport (in pixels). */
801
- getViewportSize() {
802
- return this._viewportSize;
803
- }
804
- // TODO(mmalerba): This is technically out of sync with what's really rendered until a render
805
- // cycle happens. I'm being careful to only call it after the render cycle is complete and before
806
- // setting it to something else, but its error prone and should probably be split into
807
- // `pendingRange` and `renderedRange`, the latter reflecting whats actually in the DOM.
808
- /** Get the current rendered range of items. */
809
- getRenderedRange() {
810
- return this._renderedRange;
811
- }
812
- /**
813
- * Sets the total size of all content (in pixels), including content that is not currently
814
- * rendered.
815
- */
816
- setTotalContentSize(size) {
817
- if (this._totalContentSize !== size) {
818
- this._totalContentSize = size;
819
- this._calculateSpacerSize();
820
- this._markChangeDetectionNeeded();
821
- }
822
- }
823
- /** Sets the currently rendered range of indices. */
824
- setRenderedRange(range) {
825
- if (!rangesEqual(this._renderedRange, range)) {
826
- this._renderedRangeSubject.next(this._renderedRange = range);
827
- this._markChangeDetectionNeeded(() => this._scrollStrategy.onContentRendered());
828
- }
829
- }
830
- /**
831
- * Gets the offset from the start of the viewport to the start of the rendered data (in pixels).
832
- */
833
- getOffsetToRenderedContentStart() {
834
- return this._renderedContentOffsetNeedsRewrite ? null : this._renderedContentOffset;
835
- }
671
+ class CdkVirtualScrollViewport extends CdkScrollable {
672
+ constructor(elementRef, _changeDetectorRef, ngZone, _scrollStrategy, dir, scrollDispatcher,
673
+ /**
674
+ * @deprecated `viewportRuler` parameter to become required.
675
+ * @breaking-change 11.0.0
676
+ */
677
+ viewportRuler) {
678
+ super(elementRef, scrollDispatcher, ngZone, dir);
679
+ this.elementRef = elementRef;
680
+ this._changeDetectorRef = _changeDetectorRef;
681
+ this._scrollStrategy = _scrollStrategy;
682
+ /** Emits when the viewport is detached from a CdkVirtualForOf. */
683
+ this._detachedSubject = new Subject();
684
+ /** Emits when the rendered range changes. */
685
+ this._renderedRangeSubject = new Subject();
686
+ this._orientation = 'vertical';
687
+ // Note: we don't use the typical EventEmitter here because we need to subscribe to the scroll
688
+ // strategy lazily (i.e. only if the user is actually listening to the events). We do this because
689
+ // depending on how the strategy calculates the scrolled index, it may come at a cost to
690
+ // performance.
691
+ /** Emits when the index of the first element visible in the viewport changes. */
692
+ this.scrolledIndexChange = new Observable((observer) => this._scrollStrategy.scrolledIndexChange.subscribe(index => Promise.resolve().then(() => this.ngZone.run(() => observer.next(index)))));
693
+ /** A stream that emits whenever the rendered range changes. */
694
+ this.renderedRangeStream = this._renderedRangeSubject.asObservable();
836
695
  /**
837
- * Sets the offset from the start of the viewport to either the start or end of the rendered data
838
- * (in pixels).
696
+ * The total size of all content (in pixels), including content that is not currently rendered.
839
697
  */
840
- setRenderedContentOffset(offset, to = 'to-start') {
841
- // For a horizontal viewport in a right-to-left language we need to translate along the x-axis
842
- // in the negative direction.
843
- const isRtl = this.dir && this.dir.value == 'rtl';
844
- const isHorizontal = this.orientation == 'horizontal';
845
- const axis = isHorizontal ? 'X' : 'Y';
846
- const axisDirection = isHorizontal && isRtl ? -1 : 1;
847
- let transform = `translate${axis}(${Number(axisDirection * offset)}px)`;
848
- this._renderedContentOffset = offset;
849
- if (to === 'to-end') {
850
- transform += ` translate${axis}(-100%)`;
851
- // The viewport should rewrite this as a `to-start` offset on the next render cycle. Otherwise
852
- // elements will appear to expand in the wrong direction (e.g. `mat-expansion-panel` would
853
- // expand upward).
854
- this._renderedContentOffsetNeedsRewrite = true;
855
- }
856
- if (this._renderedContentTransform != transform) {
857
- // We know this value is safe because we parse `offset` with `Number()` before passing it
858
- // into the string.
859
- this._renderedContentTransform = transform;
860
- this._markChangeDetectionNeeded(() => {
861
- if (this._renderedContentOffsetNeedsRewrite) {
862
- this._renderedContentOffset -= this.measureRenderedContentSize();
863
- this._renderedContentOffsetNeedsRewrite = false;
864
- this.setRenderedContentOffset(this._renderedContentOffset);
865
- }
866
- else {
867
- this._scrollStrategy.onRenderedOffsetChanged();
868
- }
869
- });
870
- }
871
- }
698
+ this._totalContentSize = 0;
699
+ /** A string representing the `style.width` property value to be used for the spacer element. */
700
+ this._totalContentWidth = '';
701
+ /** A string representing the `style.height` property value to be used for the spacer element. */
702
+ this._totalContentHeight = '';
703
+ /** The currently rendered range of indices. */
704
+ this._renderedRange = { start: 0, end: 0 };
705
+ /** The length of the data bound to this viewport (in number of items). */
706
+ this._dataLength = 0;
707
+ /** The size of the viewport (in pixels). */
708
+ this._viewportSize = 0;
709
+ /** The last rendered content offset that was set. */
710
+ this._renderedContentOffset = 0;
872
711
  /**
873
- * Scrolls to the given offset from the start of the viewport. Please note that this is not always
874
- * the same as setting `scrollTop` or `scrollLeft`. In a horizontal viewport with right-to-left
875
- * direction, this would be the equivalent of setting a fictional `scrollRight` property.
876
- * @param offset The offset to scroll to.
877
- * @param behavior The ScrollBehavior to use when scrolling. Default is behavior is `auto`.
712
+ * Whether the last rendered content offset was to the end of the content (and therefore needs to
713
+ * be rewritten as an offset to the start of the content).
878
714
  */
879
- scrollToOffset(offset, behavior = 'auto') {
880
- const options = { behavior };
881
- if (this.orientation === 'horizontal') {
882
- options.start = offset;
883
- }
884
- else {
885
- options.top = offset;
886
- }
887
- this.scrollTo(options);
715
+ this._renderedContentOffsetNeedsRewrite = false;
716
+ /** Whether there is a pending change detection cycle. */
717
+ this._isChangeDetectionPending = false;
718
+ /** A list of functions to run after the next change detection cycle. */
719
+ this._runAfterChangeDetection = [];
720
+ /** Subscription to changes in the viewport size. */
721
+ this._viewportChanges = Subscription.EMPTY;
722
+ if (!_scrollStrategy) {
723
+ throw Error('Error: cdk-virtual-scroll-viewport requires the "itemSize" property to be set.');
724
+ }
725
+ // @breaking-change 11.0.0 Remove null check for `viewportRuler`.
726
+ if (viewportRuler) {
727
+ this._viewportChanges = viewportRuler.change().subscribe(() => {
728
+ this.checkViewportSize();
729
+ });
888
730
  }
889
- /**
890
- * Scrolls to the offset for the given index.
891
- * @param index The index of the element to scroll to.
892
- * @param behavior The ScrollBehavior to use when scrolling. Default is behavior is `auto`.
893
- */
894
- scrollToIndex(index, behavior = 'auto') {
895
- this._scrollStrategy.scrollToIndex(index, behavior);
731
+ }
732
+ /** The direction the viewport scrolls. */
733
+ get orientation() {
734
+ return this._orientation;
735
+ }
736
+ set orientation(orientation) {
737
+ if (this._orientation !== orientation) {
738
+ this._orientation = orientation;
739
+ this._calculateSpacerSize();
896
740
  }
897
- /**
898
- * Gets the current scroll offset from the start of the viewport (in pixels).
899
- * @param from The edge to measure the offset from. Defaults to 'top' in vertical mode and 'start'
900
- * in horizontal mode.
901
- */
902
- measureScrollOffset(from) {
903
- return from ?
904
- super.measureScrollOffset(from) :
905
- super.measureScrollOffset(this.orientation === 'horizontal' ? 'start' : 'top');
741
+ }
742
+ ngOnInit() {
743
+ super.ngOnInit();
744
+ // It's still too early to measure the viewport at this point. Deferring with a promise allows
745
+ // the Viewport to be rendered with the correct size before we measure. We run this outside the
746
+ // zone to avoid causing more change detection cycles. We handle the change detection loop
747
+ // ourselves instead.
748
+ this.ngZone.runOutsideAngular(() => Promise.resolve().then(() => {
749
+ this._measureViewportSize();
750
+ this._scrollStrategy.attach(this);
751
+ this.elementScrolled()
752
+ .pipe(
753
+ // Start off with a fake scroll event so we properly detect our initial position.
754
+ startWith(null),
755
+ // Collect multiple events into one until the next animation frame. This way if
756
+ // there are multiple scroll events in the same frame we only need to recheck
757
+ // our layout once.
758
+ auditTime(0, SCROLL_SCHEDULER))
759
+ .subscribe(() => this._scrollStrategy.onContentScrolled());
760
+ this._markChangeDetectionNeeded();
761
+ }));
762
+ }
763
+ ngOnDestroy() {
764
+ this.detach();
765
+ this._scrollStrategy.detach();
766
+ // Complete all subjects
767
+ this._renderedRangeSubject.complete();
768
+ this._detachedSubject.complete();
769
+ this._viewportChanges.unsubscribe();
770
+ super.ngOnDestroy();
771
+ }
772
+ /** Attaches a `CdkVirtualScrollRepeater` to this viewport. */
773
+ attach(forOf) {
774
+ if (this._forOf) {
775
+ throw Error('CdkVirtualScrollViewport is already attached.');
776
+ }
777
+ // Subscribe to the data stream of the CdkVirtualForOf to keep track of when the data length
778
+ // changes. Run outside the zone to avoid triggering change detection, since we're managing the
779
+ // change detection loop ourselves.
780
+ this.ngZone.runOutsideAngular(() => {
781
+ this._forOf = forOf;
782
+ this._forOf.dataStream.pipe(takeUntil(this._detachedSubject)).subscribe(data => {
783
+ const newLength = data.length;
784
+ if (newLength !== this._dataLength) {
785
+ this._dataLength = newLength;
786
+ this._scrollStrategy.onDataLengthChanged();
787
+ }
788
+ this._doChangeDetection();
789
+ });
790
+ });
791
+ }
792
+ /** Detaches the current `CdkVirtualForOf`. */
793
+ detach() {
794
+ this._forOf = null;
795
+ this._detachedSubject.next();
796
+ }
797
+ /** Gets the length of the data bound to this viewport (in number of items). */
798
+ getDataLength() {
799
+ return this._dataLength;
800
+ }
801
+ /** Gets the size of the viewport (in pixels). */
802
+ getViewportSize() {
803
+ return this._viewportSize;
804
+ }
805
+ // TODO(mmalerba): This is technically out of sync with what's really rendered until a render
806
+ // cycle happens. I'm being careful to only call it after the render cycle is complete and before
807
+ // setting it to something else, but its error prone and should probably be split into
808
+ // `pendingRange` and `renderedRange`, the latter reflecting whats actually in the DOM.
809
+ /** Get the current rendered range of items. */
810
+ getRenderedRange() {
811
+ return this._renderedRange;
812
+ }
813
+ /**
814
+ * Sets the total size of all content (in pixels), including content that is not currently
815
+ * rendered.
816
+ */
817
+ setTotalContentSize(size) {
818
+ if (this._totalContentSize !== size) {
819
+ this._totalContentSize = size;
820
+ this._calculateSpacerSize();
821
+ this._markChangeDetectionNeeded();
906
822
  }
907
- /** Measure the combined size of all of the rendered items. */
908
- measureRenderedContentSize() {
909
- const contentEl = this._contentWrapper.nativeElement;
910
- return this.orientation === 'horizontal' ? contentEl.offsetWidth : contentEl.offsetHeight;
823
+ }
824
+ /** Sets the currently rendered range of indices. */
825
+ setRenderedRange(range) {
826
+ if (!rangesEqual(this._renderedRange, range)) {
827
+ this._renderedRangeSubject.next(this._renderedRange = range);
828
+ this._markChangeDetectionNeeded(() => this._scrollStrategy.onContentRendered());
911
829
  }
912
- /**
913
- * Measure the total combined size of the given range. Throws if the range includes items that are
914
- * not rendered.
915
- */
916
- measureRangeSize(range) {
917
- if (!this._forOf) {
918
- return 0;
919
- }
920
- return this._forOf.measureRangeSize(range, this.orientation);
830
+ }
831
+ /**
832
+ * Gets the offset from the start of the viewport to the start of the rendered data (in pixels).
833
+ */
834
+ getOffsetToRenderedContentStart() {
835
+ return this._renderedContentOffsetNeedsRewrite ? null : this._renderedContentOffset;
836
+ }
837
+ /**
838
+ * Sets the offset from the start of the viewport to either the start or end of the rendered data
839
+ * (in pixels).
840
+ */
841
+ setRenderedContentOffset(offset, to = 'to-start') {
842
+ // For a horizontal viewport in a right-to-left language we need to translate along the x-axis
843
+ // in the negative direction.
844
+ const isRtl = this.dir && this.dir.value == 'rtl';
845
+ const isHorizontal = this.orientation == 'horizontal';
846
+ const axis = isHorizontal ? 'X' : 'Y';
847
+ const axisDirection = isHorizontal && isRtl ? -1 : 1;
848
+ let transform = `translate${axis}(${Number(axisDirection * offset)}px)`;
849
+ this._renderedContentOffset = offset;
850
+ if (to === 'to-end') {
851
+ transform += ` translate${axis}(-100%)`;
852
+ // The viewport should rewrite this as a `to-start` offset on the next render cycle. Otherwise
853
+ // elements will appear to expand in the wrong direction (e.g. `mat-expansion-panel` would
854
+ // expand upward).
855
+ this._renderedContentOffsetNeedsRewrite = true;
856
+ }
857
+ if (this._renderedContentTransform != transform) {
858
+ // We know this value is safe because we parse `offset` with `Number()` before passing it
859
+ // into the string.
860
+ this._renderedContentTransform = transform;
861
+ this._markChangeDetectionNeeded(() => {
862
+ if (this._renderedContentOffsetNeedsRewrite) {
863
+ this._renderedContentOffset -= this.measureRenderedContentSize();
864
+ this._renderedContentOffsetNeedsRewrite = false;
865
+ this.setRenderedContentOffset(this._renderedContentOffset);
866
+ }
867
+ else {
868
+ this._scrollStrategy.onRenderedOffsetChanged();
869
+ }
870
+ });
921
871
  }
922
- /** Update the viewport dimensions and re-render. */
923
- checkViewportSize() {
924
- // TODO: Cleanup later when add logic for handling content resize
925
- this._measureViewportSize();
926
- this._scrollStrategy.onDataLengthChanged();
872
+ }
873
+ /**
874
+ * Scrolls to the given offset from the start of the viewport. Please note that this is not always
875
+ * the same as setting `scrollTop` or `scrollLeft`. In a horizontal viewport with right-to-left
876
+ * direction, this would be the equivalent of setting a fictional `scrollRight` property.
877
+ * @param offset The offset to scroll to.
878
+ * @param behavior The ScrollBehavior to use when scrolling. Default is behavior is `auto`.
879
+ */
880
+ scrollToOffset(offset, behavior = 'auto') {
881
+ const options = { behavior };
882
+ if (this.orientation === 'horizontal') {
883
+ options.start = offset;
927
884
  }
928
- /** Measure the viewport size. */
929
- _measureViewportSize() {
930
- const viewportEl = this.elementRef.nativeElement;
931
- this._viewportSize = this.orientation === 'horizontal' ?
932
- viewportEl.clientWidth : viewportEl.clientHeight;
885
+ else {
886
+ options.top = offset;
933
887
  }
934
- /** Queue up change detection to run. */
935
- _markChangeDetectionNeeded(runAfter) {
936
- if (runAfter) {
937
- this._runAfterChangeDetection.push(runAfter);
938
- }
939
- // Use a Promise to batch together calls to `_doChangeDetection`. This way if we set a bunch of
940
- // properties sequentially we only have to run `_doChangeDetection` once at the end.
941
- if (!this._isChangeDetectionPending) {
942
- this._isChangeDetectionPending = true;
943
- this.ngZone.runOutsideAngular(() => Promise.resolve().then(() => {
944
- this._doChangeDetection();
945
- }));
946
- }
888
+ this.scrollTo(options);
889
+ }
890
+ /**
891
+ * Scrolls to the offset for the given index.
892
+ * @param index The index of the element to scroll to.
893
+ * @param behavior The ScrollBehavior to use when scrolling. Default is behavior is `auto`.
894
+ */
895
+ scrollToIndex(index, behavior = 'auto') {
896
+ this._scrollStrategy.scrollToIndex(index, behavior);
897
+ }
898
+ /**
899
+ * Gets the current scroll offset from the start of the viewport (in pixels).
900
+ * @param from The edge to measure the offset from. Defaults to 'top' in vertical mode and 'start'
901
+ * in horizontal mode.
902
+ */
903
+ measureScrollOffset(from) {
904
+ return from ?
905
+ super.measureScrollOffset(from) :
906
+ super.measureScrollOffset(this.orientation === 'horizontal' ? 'start' : 'top');
907
+ }
908
+ /** Measure the combined size of all of the rendered items. */
909
+ measureRenderedContentSize() {
910
+ const contentEl = this._contentWrapper.nativeElement;
911
+ return this.orientation === 'horizontal' ? contentEl.offsetWidth : contentEl.offsetHeight;
912
+ }
913
+ /**
914
+ * Measure the total combined size of the given range. Throws if the range includes items that are
915
+ * not rendered.
916
+ */
917
+ measureRangeSize(range) {
918
+ if (!this._forOf) {
919
+ return 0;
947
920
  }
948
- /** Run change detection. */
949
- _doChangeDetection() {
950
- this._isChangeDetectionPending = false;
951
- // Apply the content transform. The transform can't be set via an Angular binding because
952
- // bypassSecurityTrustStyle is banned in Google. However the value is safe, it's composed of
953
- // string literals, a variable that can only be 'X' or 'Y', and user input that is run through
954
- // the `Number` function first to coerce it to a numeric value.
955
- this._contentWrapper.nativeElement.style.transform = this._renderedContentTransform;
956
- // Apply changes to Angular bindings. Note: We must call `markForCheck` to run change detection
957
- // from the root, since the repeated items are content projected in. Calling `detectChanges`
958
- // instead does not properly check the projected content.
959
- this.ngZone.run(() => this._changeDetectorRef.markForCheck());
960
- const runAfterChangeDetection = this._runAfterChangeDetection;
961
- this._runAfterChangeDetection = [];
962
- for (const fn of runAfterChangeDetection) {
963
- fn();
964
- }
921
+ return this._forOf.measureRangeSize(range, this.orientation);
922
+ }
923
+ /** Update the viewport dimensions and re-render. */
924
+ checkViewportSize() {
925
+ // TODO: Cleanup later when add logic for handling content resize
926
+ this._measureViewportSize();
927
+ this._scrollStrategy.onDataLengthChanged();
928
+ }
929
+ /** Measure the viewport size. */
930
+ _measureViewportSize() {
931
+ const viewportEl = this.elementRef.nativeElement;
932
+ this._viewportSize = this.orientation === 'horizontal' ?
933
+ viewportEl.clientWidth : viewportEl.clientHeight;
934
+ }
935
+ /** Queue up change detection to run. */
936
+ _markChangeDetectionNeeded(runAfter) {
937
+ if (runAfter) {
938
+ this._runAfterChangeDetection.push(runAfter);
939
+ }
940
+ // Use a Promise to batch together calls to `_doChangeDetection`. This way if we set a bunch of
941
+ // properties sequentially we only have to run `_doChangeDetection` once at the end.
942
+ if (!this._isChangeDetectionPending) {
943
+ this._isChangeDetectionPending = true;
944
+ this.ngZone.runOutsideAngular(() => Promise.resolve().then(() => {
945
+ this._doChangeDetection();
946
+ }));
965
947
  }
966
- /** Calculates the `style.width` and `style.height` for the spacer element. */
967
- _calculateSpacerSize() {
968
- this._totalContentHeight =
969
- this.orientation === 'horizontal' ? '' : `${this._totalContentSize}px`;
970
- this._totalContentWidth =
971
- this.orientation === 'horizontal' ? `${this._totalContentSize}px` : '';
948
+ }
949
+ /** Run change detection. */
950
+ _doChangeDetection() {
951
+ this._isChangeDetectionPending = false;
952
+ // Apply the content transform. The transform can't be set via an Angular binding because
953
+ // bypassSecurityTrustStyle is banned in Google. However the value is safe, it's composed of
954
+ // string literals, a variable that can only be 'X' or 'Y', and user input that is run through
955
+ // the `Number` function first to coerce it to a numeric value.
956
+ this._contentWrapper.nativeElement.style.transform = this._renderedContentTransform;
957
+ // Apply changes to Angular bindings. Note: We must call `markForCheck` to run change detection
958
+ // from the root, since the repeated items are content projected in. Calling `detectChanges`
959
+ // instead does not properly check the projected content.
960
+ this.ngZone.run(() => this._changeDetectorRef.markForCheck());
961
+ const runAfterChangeDetection = this._runAfterChangeDetection;
962
+ this._runAfterChangeDetection = [];
963
+ for (const fn of runAfterChangeDetection) {
964
+ fn();
972
965
  }
973
966
  }
974
- CdkVirtualScrollViewport.decorators = [
975
- { type: Component, args: [{
976
- selector: 'cdk-virtual-scroll-viewport',
977
- template: "<!--\n Wrap the rendered content in an element that will be used to offset it based on the scroll\n position.\n-->\n<div #contentWrapper class=\"cdk-virtual-scroll-content-wrapper\">\n <ng-content></ng-content>\n</div>\n<!--\n Spacer used to force the scrolling container to the correct size for the *total* number of items\n so that the scrollbar captures the size of the entire data set.\n-->\n<div class=\"cdk-virtual-scroll-spacer\"\n [style.width]=\"_totalContentWidth\" [style.height]=\"_totalContentHeight\"></div>\n",
978
- host: {
979
- 'class': 'cdk-virtual-scroll-viewport',
980
- '[class.cdk-virtual-scroll-orientation-horizontal]': 'orientation === "horizontal"',
981
- '[class.cdk-virtual-scroll-orientation-vertical]': 'orientation !== "horizontal"',
982
- },
983
- encapsulation: ViewEncapsulation.None,
984
- changeDetection: ChangeDetectionStrategy.OnPush,
985
- providers: [{
986
- provide: CdkScrollable,
987
- useExisting: CdkVirtualScrollViewport,
988
- }],
989
- styles: ["cdk-virtual-scroll-viewport{display:block;position:relative;overflow:auto;contain:strict;transform:translateZ(0);will-change:scroll-position;-webkit-overflow-scrolling:touch}.cdk-virtual-scroll-content-wrapper{position:absolute;top:0;left:0;contain:content}[dir=rtl] .cdk-virtual-scroll-content-wrapper{right:0;left:auto}.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper{min-height:100%}.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper>dl:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper>ol:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper>table:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper>ul:not([cdkVirtualFor]){padding-left:0;padding-right:0;margin-left:0;margin-right:0;border-left-width:0;border-right-width:0;outline:none}.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper{min-width:100%}.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper>dl:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper>ol:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper>table:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper>ul:not([cdkVirtualFor]){padding-top:0;padding-bottom:0;margin-top:0;margin-bottom:0;border-top-width:0;border-bottom-width:0;outline:none}.cdk-virtual-scroll-spacer{position:absolute;top:0;left:0;height:1px;width:1px;transform-origin:0 0}[dir=rtl] .cdk-virtual-scroll-spacer{right:0;left:auto;transform-origin:100% 0}\n"]
990
- },] }
991
- ];
992
- CdkVirtualScrollViewport.ctorParameters = () => [
993
- { type: ElementRef },
994
- { type: ChangeDetectorRef },
995
- { type: NgZone },
996
- { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [VIRTUAL_SCROLL_STRATEGY,] }] },
997
- { type: Directionality, decorators: [{ type: Optional }] },
998
- { type: ScrollDispatcher },
999
- { type: ViewportRuler, decorators: [{ type: Optional }] }
1000
- ];
1001
- CdkVirtualScrollViewport.propDecorators = {
1002
- orientation: [{ type: Input }],
1003
- scrolledIndexChange: [{ type: Output }],
1004
- _contentWrapper: [{ type: ViewChild, args: ['contentWrapper', { static: true },] }]
1005
- };
1006
- return CdkVirtualScrollViewport;
1007
- })();
967
+ /** Calculates the `style.width` and `style.height` for the spacer element. */
968
+ _calculateSpacerSize() {
969
+ this._totalContentHeight =
970
+ this.orientation === 'horizontal' ? '' : `${this._totalContentSize}px`;
971
+ this._totalContentWidth =
972
+ this.orientation === 'horizontal' ? `${this._totalContentSize}px` : '';
973
+ }
974
+ }
975
+ CdkVirtualScrollViewport.decorators = [
976
+ { type: Component, args: [{
977
+ selector: 'cdk-virtual-scroll-viewport',
978
+ template: "<!--\n Wrap the rendered content in an element that will be used to offset it based on the scroll\n position.\n-->\n<div #contentWrapper class=\"cdk-virtual-scroll-content-wrapper\">\n <ng-content></ng-content>\n</div>\n<!--\n Spacer used to force the scrolling container to the correct size for the *total* number of items\n so that the scrollbar captures the size of the entire data set.\n-->\n<div class=\"cdk-virtual-scroll-spacer\"\n [style.width]=\"_totalContentWidth\" [style.height]=\"_totalContentHeight\"></div>\n",
979
+ host: {
980
+ 'class': 'cdk-virtual-scroll-viewport',
981
+ '[class.cdk-virtual-scroll-orientation-horizontal]': 'orientation === "horizontal"',
982
+ '[class.cdk-virtual-scroll-orientation-vertical]': 'orientation !== "horizontal"',
983
+ },
984
+ encapsulation: ViewEncapsulation.None,
985
+ changeDetection: ChangeDetectionStrategy.OnPush,
986
+ providers: [{
987
+ provide: CdkScrollable,
988
+ useExisting: CdkVirtualScrollViewport,
989
+ }],
990
+ styles: ["cdk-virtual-scroll-viewport{display:block;position:relative;overflow:auto;contain:strict;transform:translateZ(0);will-change:scroll-position;-webkit-overflow-scrolling:touch}.cdk-virtual-scroll-content-wrapper{position:absolute;top:0;left:0;contain:content}[dir=rtl] .cdk-virtual-scroll-content-wrapper{right:0;left:auto}.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper{min-height:100%}.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper>dl:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper>ol:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper>table:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper>ul:not([cdkVirtualFor]){padding-left:0;padding-right:0;margin-left:0;margin-right:0;border-left-width:0;border-right-width:0;outline:none}.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper{min-width:100%}.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper>dl:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper>ol:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper>table:not([cdkVirtualFor]),.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper>ul:not([cdkVirtualFor]){padding-top:0;padding-bottom:0;margin-top:0;margin-bottom:0;border-top-width:0;border-bottom-width:0;outline:none}.cdk-virtual-scroll-spacer{position:absolute;top:0;left:0;height:1px;width:1px;transform-origin:0 0}[dir=rtl] .cdk-virtual-scroll-spacer{right:0;left:auto;transform-origin:100% 0}\n"]
991
+ },] }
992
+ ];
993
+ CdkVirtualScrollViewport.ctorParameters = () => [
994
+ { type: ElementRef },
995
+ { type: ChangeDetectorRef },
996
+ { type: NgZone },
997
+ { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [VIRTUAL_SCROLL_STRATEGY,] }] },
998
+ { type: Directionality, decorators: [{ type: Optional }] },
999
+ { type: ScrollDispatcher },
1000
+ { type: ViewportRuler, decorators: [{ type: Optional }] }
1001
+ ];
1002
+ CdkVirtualScrollViewport.propDecorators = {
1003
+ orientation: [{ type: Input }],
1004
+ scrolledIndexChange: [{ type: Output }],
1005
+ _contentWrapper: [{ type: ViewChild, args: ['contentWrapper', { static: true },] }]
1006
+ };
1008
1007
 
1009
1008
  /**
1010
1009
  * @license
@@ -1026,297 +1025,333 @@ function getSize(orientation, node) {
1026
1025
  * A directive similar to `ngForOf` to be used for rendering data inside a virtual scrolling
1027
1026
  * container.
1028
1027
  */
1029
- let CdkVirtualForOf = /** @class */ (() => {
1030
- class CdkVirtualForOf {
1031
- constructor(
1032
- /** The view container to add items to. */
1033
- _viewContainerRef,
1034
- /** The template to use when stamping out new items. */
1035
- _template,
1036
- /** The set of available differs. */
1037
- _differs,
1038
- /** The virtual scrolling viewport that these items are being rendered in. */
1039
- _viewport, ngZone) {
1040
- this._viewContainerRef = _viewContainerRef;
1041
- this._template = _template;
1042
- this._differs = _differs;
1043
- this._viewport = _viewport;
1044
- /** Emits when the rendered view of the data changes. */
1045
- this.viewChange = new Subject();
1046
- /** Subject that emits when a new DataSource instance is given. */
1047
- this._dataSourceChanges = new Subject();
1048
- /**
1049
- * The size of the cache used to store templates that are not being used for re-use later.
1050
- * Setting the cache size to `0` will disable caching. Defaults to 20 templates.
1051
- */
1052
- this.cdkVirtualForTemplateCacheSize = 20;
1053
- /** Emits whenever the data in the current DataSource changes. */
1054
- this.dataStream = this._dataSourceChanges
1055
- .pipe(
1056
- // Start off with null `DataSource`.
1057
- startWith(null),
1058
- // Bundle up the previous and current data sources so we can work with both.
1059
- pairwise(),
1060
- // Use `_changeDataSource` to disconnect from the previous data source and connect to the
1061
- // new one, passing back a stream of data changes which we run through `switchMap` to give
1062
- // us a data stream that emits the latest data from whatever the current `DataSource` is.
1063
- switchMap(([prev, cur]) => this._changeDataSource(prev, cur)),
1064
- // Replay the last emitted data when someone subscribes.
1065
- shareReplay(1));
1066
- /** The differ used to calculate changes to the data. */
1067
- this._differ = null;
1068
- /**
1069
- * The template cache used to hold on ot template instancess that have been stamped out, but don't
1070
- * currently need to be rendered. These instances will be reused in the future rather than
1071
- * stamping out brand new ones.
1072
- */
1073
- this._templateCache = [];
1074
- /** Whether the rendered data should be updated during the next ngDoCheck cycle. */
1075
- this._needsUpdate = false;
1076
- this._destroyed = new Subject();
1077
- this.dataStream.subscribe(data => {
1078
- this._data = data;
1079
- this._onRenderedDataChange();
1080
- });
1081
- this._viewport.renderedRangeStream.pipe(takeUntil(this._destroyed)).subscribe(range => {
1082
- this._renderedRange = range;
1083
- ngZone.run(() => this.viewChange.next(this._renderedRange));
1084
- this._onRenderedDataChange();
1085
- });
1086
- this._viewport.attach(this);
1087
- }
1088
- /** The DataSource to display. */
1089
- get cdkVirtualForOf() {
1090
- return this._cdkVirtualForOf;
1091
- }
1092
- set cdkVirtualForOf(value) {
1093
- this._cdkVirtualForOf = value;
1094
- if (isDataSource(value)) {
1095
- this._dataSourceChanges.next(value);
1096
- }
1097
- else {
1098
- // Slice the value if its an NgIterable to ensure we're working with an array.
1099
- this._dataSourceChanges.next(new ArrayDataSource(isObservable(value) ? value : Array.prototype.slice.call(value || [])));
1100
- }
1101
- }
1028
+ class CdkVirtualForOf {
1029
+ constructor(
1030
+ /** The view container to add items to. */
1031
+ _viewContainerRef,
1032
+ /** The template to use when stamping out new items. */
1033
+ _template,
1034
+ /** The set of available differs. */
1035
+ _differs,
1036
+ /** The virtual scrolling viewport that these items are being rendered in. */
1037
+ _viewport, ngZone) {
1038
+ this._viewContainerRef = _viewContainerRef;
1039
+ this._template = _template;
1040
+ this._differs = _differs;
1041
+ this._viewport = _viewport;
1042
+ /** Emits when the rendered view of the data changes. */
1043
+ this.viewChange = new Subject();
1044
+ /** Subject that emits when a new DataSource instance is given. */
1045
+ this._dataSourceChanges = new Subject();
1102
1046
  /**
1103
- * The `TrackByFunction` to use for tracking changes. The `TrackByFunction` takes the index and
1104
- * the item and produces a value to be used as the item's identity when tracking changes.
1047
+ * The size of the cache used to store templates that are not being used for re-use later.
1048
+ * Setting the cache size to `0` will disable caching. Defaults to 20 templates.
1105
1049
  */
1106
- get cdkVirtualForTrackBy() {
1107
- return this._cdkVirtualForTrackBy;
1050
+ this.cdkVirtualForTemplateCacheSize = 20;
1051
+ /** Emits whenever the data in the current DataSource changes. */
1052
+ this.dataStream = this._dataSourceChanges
1053
+ .pipe(
1054
+ // Start off with null `DataSource`.
1055
+ startWith(null),
1056
+ // Bundle up the previous and current data sources so we can work with both.
1057
+ pairwise(),
1058
+ // Use `_changeDataSource` to disconnect from the previous data source and connect to the
1059
+ // new one, passing back a stream of data changes which we run through `switchMap` to give
1060
+ // us a data stream that emits the latest data from whatever the current `DataSource` is.
1061
+ switchMap(([prev, cur]) => this._changeDataSource(prev, cur)),
1062
+ // Replay the last emitted data when someone subscribes.
1063
+ shareReplay(1));
1064
+ /** The differ used to calculate changes to the data. */
1065
+ this._differ = null;
1066
+ /**
1067
+ * The template cache used to hold on ot template instancess that have been stamped out, but don't
1068
+ * currently need to be rendered. These instances will be reused in the future rather than
1069
+ * stamping out brand new ones.
1070
+ */
1071
+ this._templateCache = [];
1072
+ /** Whether the rendered data should be updated during the next ngDoCheck cycle. */
1073
+ this._needsUpdate = false;
1074
+ this._destroyed = new Subject();
1075
+ this.dataStream.subscribe(data => {
1076
+ this._data = data;
1077
+ this._onRenderedDataChange();
1078
+ });
1079
+ this._viewport.renderedRangeStream.pipe(takeUntil(this._destroyed)).subscribe(range => {
1080
+ this._renderedRange = range;
1081
+ ngZone.run(() => this.viewChange.next(this._renderedRange));
1082
+ this._onRenderedDataChange();
1083
+ });
1084
+ this._viewport.attach(this);
1085
+ }
1086
+ /** The DataSource to display. */
1087
+ get cdkVirtualForOf() {
1088
+ return this._cdkVirtualForOf;
1089
+ }
1090
+ set cdkVirtualForOf(value) {
1091
+ this._cdkVirtualForOf = value;
1092
+ if (isDataSource(value)) {
1093
+ this._dataSourceChanges.next(value);
1094
+ }
1095
+ else {
1096
+ // Slice the value if its an NgIterable to ensure we're working with an array.
1097
+ this._dataSourceChanges.next(new ArrayDataSource(isObservable(value) ? value : Array.prototype.slice.call(value || [])));
1108
1098
  }
1109
- set cdkVirtualForTrackBy(fn) {
1099
+ }
1100
+ /**
1101
+ * The `TrackByFunction` to use for tracking changes. The `TrackByFunction` takes the index and
1102
+ * the item and produces a value to be used as the item's identity when tracking changes.
1103
+ */
1104
+ get cdkVirtualForTrackBy() {
1105
+ return this._cdkVirtualForTrackBy;
1106
+ }
1107
+ set cdkVirtualForTrackBy(fn) {
1108
+ this._needsUpdate = true;
1109
+ this._cdkVirtualForTrackBy = fn ?
1110
+ (index, item) => fn(index + (this._renderedRange ? this._renderedRange.start : 0), item) :
1111
+ undefined;
1112
+ }
1113
+ /** The template used to stamp out new elements. */
1114
+ set cdkVirtualForTemplate(value) {
1115
+ if (value) {
1110
1116
  this._needsUpdate = true;
1111
- this._cdkVirtualForTrackBy = fn ?
1112
- (index, item) => fn(index + (this._renderedRange ? this._renderedRange.start : 0), item) :
1113
- undefined;
1117
+ this._template = value;
1114
1118
  }
1115
- /** The template used to stamp out new elements. */
1116
- set cdkVirtualForTemplate(value) {
1117
- if (value) {
1118
- this._needsUpdate = true;
1119
- this._template = value;
1119
+ }
1120
+ /**
1121
+ * Measures the combined size (width for horizontal orientation, height for vertical) of all items
1122
+ * in the specified range. Throws an error if the range includes items that are not currently
1123
+ * rendered.
1124
+ */
1125
+ measureRangeSize(range, orientation) {
1126
+ if (range.start >= range.end) {
1127
+ return 0;
1128
+ }
1129
+ if (range.start < this._renderedRange.start || range.end > this._renderedRange.end) {
1130
+ throw Error(`Error: attempted to measure an item that isn't rendered.`);
1131
+ }
1132
+ // The index into the list of rendered views for the first item in the range.
1133
+ const renderedStartIndex = range.start - this._renderedRange.start;
1134
+ // The length of the range we're measuring.
1135
+ const rangeLen = range.end - range.start;
1136
+ // Loop over all root nodes for all items in the range and sum up their size.
1137
+ let totalSize = 0;
1138
+ let i = rangeLen;
1139
+ while (i--) {
1140
+ const view = this._viewContainerRef.get(i + renderedStartIndex);
1141
+ let j = view ? view.rootNodes.length : 0;
1142
+ while (j--) {
1143
+ totalSize += getSize(orientation, view.rootNodes[j]);
1120
1144
  }
1121
1145
  }
1122
- /**
1123
- * Measures the combined size (width for horizontal orientation, height for vertical) of all items
1124
- * in the specified range. Throws an error if the range includes items that are not currently
1125
- * rendered.
1126
- */
1127
- measureRangeSize(range, orientation) {
1128
- if (range.start >= range.end) {
1129
- return 0;
1130
- }
1131
- if (range.start < this._renderedRange.start || range.end > this._renderedRange.end) {
1132
- throw Error(`Error: attempted to measure an item that isn't rendered.`);
1146
+ return totalSize;
1147
+ }
1148
+ ngDoCheck() {
1149
+ if (this._differ && this._needsUpdate) {
1150
+ // TODO(mmalerba): We should differentiate needs update due to scrolling and a new portion of
1151
+ // this list being rendered (can use simpler algorithm) vs needs update due to data actually
1152
+ // changing (need to do this diff).
1153
+ const changes = this._differ.diff(this._renderedItems);
1154
+ if (!changes) {
1155
+ this._updateContext();
1133
1156
  }
1134
- // The index into the list of rendered views for the first item in the range.
1135
- const renderedStartIndex = range.start - this._renderedRange.start;
1136
- // The length of the range we're measuring.
1137
- const rangeLen = range.end - range.start;
1138
- // Loop over all root nodes for all items in the range and sum up their size.
1139
- let totalSize = 0;
1140
- let i = rangeLen;
1141
- while (i--) {
1142
- const view = this._viewContainerRef.get(i + renderedStartIndex);
1143
- let j = view ? view.rootNodes.length : 0;
1144
- while (j--) {
1145
- totalSize += getSize(orientation, view.rootNodes[j]);
1146
- }
1157
+ else {
1158
+ this._applyChanges(changes);
1147
1159
  }
1148
- return totalSize;
1160
+ this._needsUpdate = false;
1149
1161
  }
1150
- ngDoCheck() {
1151
- if (this._differ && this._needsUpdate) {
1152
- // TODO(mmalerba): We should differentiate needs update due to scrolling and a new portion of
1153
- // this list being rendered (can use simpler algorithm) vs needs update due to data actually
1154
- // changing (need to do this diff).
1155
- const changes = this._differ.diff(this._renderedItems);
1156
- if (!changes) {
1157
- this._updateContext();
1158
- }
1159
- else {
1160
- this._applyChanges(changes);
1161
- }
1162
- this._needsUpdate = false;
1163
- }
1162
+ }
1163
+ ngOnDestroy() {
1164
+ this._viewport.detach();
1165
+ this._dataSourceChanges.next(undefined);
1166
+ this._dataSourceChanges.complete();
1167
+ this.viewChange.complete();
1168
+ this._destroyed.next();
1169
+ this._destroyed.complete();
1170
+ for (let view of this._templateCache) {
1171
+ view.destroy();
1164
1172
  }
1165
- ngOnDestroy() {
1166
- this._viewport.detach();
1167
- this._dataSourceChanges.next();
1168
- this._dataSourceChanges.complete();
1169
- this.viewChange.complete();
1170
- this._destroyed.next();
1171
- this._destroyed.complete();
1172
- for (let view of this._templateCache) {
1173
- view.destroy();
1174
- }
1173
+ }
1174
+ /** React to scroll state changes in the viewport. */
1175
+ _onRenderedDataChange() {
1176
+ if (!this._renderedRange) {
1177
+ return;
1175
1178
  }
1176
- /** React to scroll state changes in the viewport. */
1177
- _onRenderedDataChange() {
1178
- if (!this._renderedRange) {
1179
- return;
1180
- }
1181
- this._renderedItems = this._data.slice(this._renderedRange.start, this._renderedRange.end);
1182
- if (!this._differ) {
1183
- this._differ = this._differs.find(this._renderedItems).create(this.cdkVirtualForTrackBy);
1184
- }
1185
- this._needsUpdate = true;
1179
+ this._renderedItems = this._data.slice(this._renderedRange.start, this._renderedRange.end);
1180
+ if (!this._differ) {
1181
+ this._differ = this._differs.find(this._renderedItems).create(this.cdkVirtualForTrackBy);
1186
1182
  }
1187
- /** Swap out one `DataSource` for another. */
1188
- _changeDataSource(oldDs, newDs) {
1189
- if (oldDs) {
1190
- oldDs.disconnect(this);
1191
- }
1192
- this._needsUpdate = true;
1193
- return newDs ? newDs.connect(this) : of();
1183
+ this._needsUpdate = true;
1184
+ }
1185
+ /** Swap out one `DataSource` for another. */
1186
+ _changeDataSource(oldDs, newDs) {
1187
+ if (oldDs) {
1188
+ oldDs.disconnect(this);
1194
1189
  }
1195
- /** Update the `CdkVirtualForOfContext` for all views. */
1196
- _updateContext() {
1197
- const count = this._data.length;
1198
- let i = this._viewContainerRef.length;
1199
- while (i--) {
1200
- let view = this._viewContainerRef.get(i);
1201
- view.context.index = this._renderedRange.start + i;
1202
- view.context.count = count;
1203
- this._updateComputedContextProperties(view.context);
1204
- view.detectChanges();
1205
- }
1190
+ this._needsUpdate = true;
1191
+ return newDs ? newDs.connect(this) : of();
1192
+ }
1193
+ /** Update the `CdkVirtualForOfContext` for all views. */
1194
+ _updateContext() {
1195
+ const count = this._data.length;
1196
+ let i = this._viewContainerRef.length;
1197
+ while (i--) {
1198
+ let view = this._viewContainerRef.get(i);
1199
+ view.context.index = this._renderedRange.start + i;
1200
+ view.context.count = count;
1201
+ this._updateComputedContextProperties(view.context);
1202
+ view.detectChanges();
1206
1203
  }
1207
- /** Apply changes to the DOM. */
1208
- _applyChanges(changes) {
1209
- // Rearrange the views to put them in the right location.
1210
- changes.forEachOperation((record, adjustedPreviousIndex, currentIndex) => {
1211
- if (record.previousIndex == null) { // Item added.
1212
- const view = this._insertViewForNewItem(currentIndex);
1213
- view.context.$implicit = record.item;
1214
- }
1215
- else if (currentIndex == null) { // Item removed.
1216
- this._cacheView(this._detachView(adjustedPreviousIndex));
1217
- }
1218
- else { // Item moved.
1219
- const view = this._viewContainerRef.get(adjustedPreviousIndex);
1220
- this._viewContainerRef.move(view, currentIndex);
1221
- view.context.$implicit = record.item;
1222
- }
1223
- });
1224
- // Update $implicit for any items that had an identity change.
1225
- changes.forEachIdentityChange((record) => {
1226
- const view = this._viewContainerRef.get(record.currentIndex);
1204
+ }
1205
+ /** Apply changes to the DOM. */
1206
+ _applyChanges(changes) {
1207
+ // Rearrange the views to put them in the right location.
1208
+ changes.forEachOperation((record, adjustedPreviousIndex, currentIndex) => {
1209
+ if (record.previousIndex == null) { // Item added.
1210
+ const view = this._insertViewForNewItem(currentIndex);
1227
1211
  view.context.$implicit = record.item;
1228
- });
1229
- // Update the context variables on all items.
1230
- const count = this._data.length;
1231
- let i = this._viewContainerRef.length;
1232
- while (i--) {
1233
- const view = this._viewContainerRef.get(i);
1234
- view.context.index = this._renderedRange.start + i;
1235
- view.context.count = count;
1236
- this._updateComputedContextProperties(view.context);
1237
1212
  }
1238
- }
1239
- /** Cache the given detached view. */
1240
- _cacheView(view) {
1241
- if (this._templateCache.length < this.cdkVirtualForTemplateCacheSize) {
1242
- this._templateCache.push(view);
1213
+ else if (currentIndex == null) { // Item removed.
1214
+ this._cacheView(this._detachView(adjustedPreviousIndex));
1243
1215
  }
1244
- else {
1245
- const index = this._viewContainerRef.indexOf(view);
1246
- // It's very unlikely that the index will ever be -1, but just in case,
1247
- // destroy the view on its own, otherwise destroy it through the
1248
- // container to ensure that all the references are removed.
1249
- if (index === -1) {
1250
- view.destroy();
1251
- }
1252
- else {
1253
- this._viewContainerRef.remove(index);
1254
- }
1216
+ else { // Item moved.
1217
+ const view = this._viewContainerRef.get(adjustedPreviousIndex);
1218
+ this._viewContainerRef.move(view, currentIndex);
1219
+ view.context.$implicit = record.item;
1255
1220
  }
1221
+ });
1222
+ // Update $implicit for any items that had an identity change.
1223
+ changes.forEachIdentityChange((record) => {
1224
+ const view = this._viewContainerRef.get(record.currentIndex);
1225
+ view.context.$implicit = record.item;
1226
+ });
1227
+ // Update the context variables on all items.
1228
+ const count = this._data.length;
1229
+ let i = this._viewContainerRef.length;
1230
+ while (i--) {
1231
+ const view = this._viewContainerRef.get(i);
1232
+ view.context.index = this._renderedRange.start + i;
1233
+ view.context.count = count;
1234
+ this._updateComputedContextProperties(view.context);
1256
1235
  }
1257
- /** Inserts a view for a new item, either from the cache or by creating a new one. */
1258
- _insertViewForNewItem(index) {
1259
- return this._insertViewFromCache(index) || this._createEmbeddedViewAt(index);
1260
- }
1261
- /** Update the computed properties on the `CdkVirtualForOfContext`. */
1262
- _updateComputedContextProperties(context) {
1263
- context.first = context.index === 0;
1264
- context.last = context.index === context.count - 1;
1265
- context.even = context.index % 2 === 0;
1266
- context.odd = !context.even;
1267
- }
1268
- /** Creates a new embedded view and moves it to the given index */
1269
- _createEmbeddedViewAt(index) {
1270
- // Note that it's important that we insert the item directly at the proper index,
1271
- // rather than inserting it and the moving it in place, because if there's a directive
1272
- // on the same node that injects the `ViewContainerRef`, Angular will insert another
1273
- // comment node which can throw off the move when it's being repeated for all items.
1274
- return this._viewContainerRef.createEmbeddedView(this._template, {
1275
- $implicit: null,
1276
- // It's guaranteed that the iterable is not "undefined" or "null" because we only
1277
- // generate views for elements if the "cdkVirtualForOf" iterable has elements.
1278
- cdkVirtualForOf: this._cdkVirtualForOf,
1279
- index: -1,
1280
- count: -1,
1281
- first: false,
1282
- last: false,
1283
- odd: false,
1284
- even: false
1285
- }, index);
1236
+ }
1237
+ /** Cache the given detached view. */
1238
+ _cacheView(view) {
1239
+ if (this._templateCache.length < this.cdkVirtualForTemplateCacheSize) {
1240
+ this._templateCache.push(view);
1286
1241
  }
1287
- /** Inserts a recycled view from the cache at the given index. */
1288
- _insertViewFromCache(index) {
1289
- const cachedView = this._templateCache.pop();
1290
- if (cachedView) {
1291
- this._viewContainerRef.insert(cachedView, index);
1242
+ else {
1243
+ const index = this._viewContainerRef.indexOf(view);
1244
+ // It's very unlikely that the index will ever be -1, but just in case,
1245
+ // destroy the view on its own, otherwise destroy it through the
1246
+ // container to ensure that all the references are removed.
1247
+ if (index === -1) {
1248
+ view.destroy();
1249
+ }
1250
+ else {
1251
+ this._viewContainerRef.remove(index);
1292
1252
  }
1293
- return cachedView || null;
1294
1253
  }
1295
- /** Detaches the embedded view at the given index. */
1296
- _detachView(index) {
1297
- return this._viewContainerRef.detach(index);
1254
+ }
1255
+ /** Inserts a view for a new item, either from the cache or by creating a new one. */
1256
+ _insertViewForNewItem(index) {
1257
+ return this._insertViewFromCache(index) || this._createEmbeddedViewAt(index);
1258
+ }
1259
+ /** Update the computed properties on the `CdkVirtualForOfContext`. */
1260
+ _updateComputedContextProperties(context) {
1261
+ context.first = context.index === 0;
1262
+ context.last = context.index === context.count - 1;
1263
+ context.even = context.index % 2 === 0;
1264
+ context.odd = !context.even;
1265
+ }
1266
+ /** Creates a new embedded view and moves it to the given index */
1267
+ _createEmbeddedViewAt(index) {
1268
+ // Note that it's important that we insert the item directly at the proper index,
1269
+ // rather than inserting it and the moving it in place, because if there's a directive
1270
+ // on the same node that injects the `ViewContainerRef`, Angular will insert another
1271
+ // comment node which can throw off the move when it's being repeated for all items.
1272
+ return this._viewContainerRef.createEmbeddedView(this._template, {
1273
+ $implicit: null,
1274
+ // It's guaranteed that the iterable is not "undefined" or "null" because we only
1275
+ // generate views for elements if the "cdkVirtualForOf" iterable has elements.
1276
+ cdkVirtualForOf: this._cdkVirtualForOf,
1277
+ index: -1,
1278
+ count: -1,
1279
+ first: false,
1280
+ last: false,
1281
+ odd: false,
1282
+ even: false
1283
+ }, index);
1284
+ }
1285
+ /** Inserts a recycled view from the cache at the given index. */
1286
+ _insertViewFromCache(index) {
1287
+ const cachedView = this._templateCache.pop();
1288
+ if (cachedView) {
1289
+ this._viewContainerRef.insert(cachedView, index);
1298
1290
  }
1291
+ return cachedView || null;
1299
1292
  }
1300
- CdkVirtualForOf.decorators = [
1301
- { type: Directive, args: [{
1302
- selector: '[cdkVirtualFor][cdkVirtualForOf]',
1303
- },] }
1304
- ];
1305
- CdkVirtualForOf.ctorParameters = () => [
1306
- { type: ViewContainerRef },
1307
- { type: TemplateRef },
1308
- { type: IterableDiffers },
1309
- { type: CdkVirtualScrollViewport, decorators: [{ type: SkipSelf }] },
1310
- { type: NgZone }
1311
- ];
1312
- CdkVirtualForOf.propDecorators = {
1313
- cdkVirtualForOf: [{ type: Input }],
1314
- cdkVirtualForTrackBy: [{ type: Input }],
1315
- cdkVirtualForTemplate: [{ type: Input }],
1316
- cdkVirtualForTemplateCacheSize: [{ type: Input }]
1317
- };
1318
- return CdkVirtualForOf;
1319
- })();
1293
+ /** Detaches the embedded view at the given index. */
1294
+ _detachView(index) {
1295
+ return this._viewContainerRef.detach(index);
1296
+ }
1297
+ }
1298
+ CdkVirtualForOf.decorators = [
1299
+ { type: Directive, args: [{
1300
+ selector: '[cdkVirtualFor][cdkVirtualForOf]',
1301
+ },] }
1302
+ ];
1303
+ CdkVirtualForOf.ctorParameters = () => [
1304
+ { type: ViewContainerRef },
1305
+ { type: TemplateRef },
1306
+ { type: IterableDiffers },
1307
+ { type: CdkVirtualScrollViewport, decorators: [{ type: SkipSelf }] },
1308
+ { type: NgZone }
1309
+ ];
1310
+ CdkVirtualForOf.propDecorators = {
1311
+ cdkVirtualForOf: [{ type: Input }],
1312
+ cdkVirtualForTrackBy: [{ type: Input }],
1313
+ cdkVirtualForTemplate: [{ type: Input }],
1314
+ cdkVirtualForTemplateCacheSize: [{ type: Input }]
1315
+ };
1316
+
1317
+ /**
1318
+ * @license
1319
+ * Copyright Google LLC All Rights Reserved.
1320
+ *
1321
+ * Use of this source code is governed by an MIT-style license that can be
1322
+ * found in the LICENSE file at https://angular.io/license
1323
+ */
1324
+ class CdkScrollableModule {
1325
+ }
1326
+ CdkScrollableModule.decorators = [
1327
+ { type: NgModule, args: [{
1328
+ exports: [CdkScrollable],
1329
+ declarations: [CdkScrollable]
1330
+ },] }
1331
+ ];
1332
+ class ScrollingModule {
1333
+ }
1334
+ ScrollingModule.decorators = [
1335
+ { type: NgModule, args: [{
1336
+ imports: [
1337
+ BidiModule,
1338
+ PlatformModule,
1339
+ CdkScrollableModule
1340
+ ],
1341
+ exports: [
1342
+ BidiModule,
1343
+ CdkScrollableModule,
1344
+ CdkFixedSizeVirtualScroll,
1345
+ CdkVirtualForOf,
1346
+ CdkVirtualScrollViewport,
1347
+ ],
1348
+ declarations: [
1349
+ CdkFixedSizeVirtualScroll,
1350
+ CdkVirtualForOf,
1351
+ CdkVirtualScrollViewport,
1352
+ ],
1353
+ },] }
1354
+ ];
1320
1355
 
1321
1356
  /**
1322
1357
  * @license
@@ -1325,43 +1360,6 @@ let CdkVirtualForOf = /** @class */ (() => {
1325
1360
  * Use of this source code is governed by an MIT-style license that can be
1326
1361
  * found in the LICENSE file at https://angular.io/license
1327
1362
  */
1328
- let CdkScrollableModule = /** @class */ (() => {
1329
- class CdkScrollableModule {
1330
- }
1331
- CdkScrollableModule.decorators = [
1332
- { type: NgModule, args: [{
1333
- exports: [CdkScrollable],
1334
- declarations: [CdkScrollable]
1335
- },] }
1336
- ];
1337
- return CdkScrollableModule;
1338
- })();
1339
- let ScrollingModule = /** @class */ (() => {
1340
- class ScrollingModule {
1341
- }
1342
- ScrollingModule.decorators = [
1343
- { type: NgModule, args: [{
1344
- imports: [
1345
- BidiModule,
1346
- PlatformModule,
1347
- CdkScrollableModule
1348
- ],
1349
- exports: [
1350
- BidiModule,
1351
- CdkScrollableModule,
1352
- CdkFixedSizeVirtualScroll,
1353
- CdkVirtualForOf,
1354
- CdkVirtualScrollViewport,
1355
- ],
1356
- declarations: [
1357
- CdkFixedSizeVirtualScroll,
1358
- CdkVirtualForOf,
1359
- CdkVirtualScrollViewport,
1360
- ],
1361
- },] }
1362
- ];
1363
- return ScrollingModule;
1364
- })();
1365
1363
 
1366
1364
  /**
1367
1365
  * @license