@@ -25,46 +25,6 @@ import {
2525} from './sticky-position-listener' ;
2626import { _TABLE_VIEW_CHANGE_STRATEGY , CdkTable , RenderRow , RowContext } from './table' ;
2727
28- /**
29- * An implementation of {@link StickyPositioningListener} that forwards sticky updates to another
30- * listener.
31- *
32- * The {@link CdkTableVirtualScroll} directive cannot provide itself as a
33- * {@link StickyPositioningListener} because the providers for both entities would point to the same
34- * instance. The {@link CdkTable} depends on the sticky positioning listener and the table virtual
35- * scroll depends on the table. Since the sticky positioning listener and table virtual scroll would
36- * be the same instance, this would create a circular dependency.
37- *
38- * The {@link CdkTableVirtualScroll} instead provides this class and attaches itself as the
39- * receiving listener so {@link StickyPositioningListener} and {@link CdkTableVirtualScroll} are
40- * provided as separate instances.
41- *
42- * @docs -private
43- */
44- export class _PositioningListenerProxy implements StickyPositioningListener {
45- private _listener ?: StickyPositioningListener ;
46-
47- setListener ( listener : StickyPositioningListener ) {
48- this . _listener = listener ;
49- }
50-
51- stickyColumnsUpdated ( update : StickyUpdate ) : void {
52- this . _listener ?. stickyColumnsUpdated ( update ) ;
53- }
54-
55- stickyEndColumnsUpdated ( update : StickyUpdate ) : void {
56- this . _listener ?. stickyEndColumnsUpdated ( update ) ;
57- }
58-
59- stickyFooterRowsUpdated ( update : StickyUpdate ) : void {
60- this . _listener ?. stickyFooterRowsUpdated ( update ) ;
61- }
62-
63- stickyHeaderRowsUpdated ( update : StickyUpdate ) : void {
64- this . _listener ?. stickyHeaderRowsUpdated ( update ) ;
65- }
66- }
67-
6828/** @docs -private */
6929export const _TABLE_VIRTUAL_SCROLL_COLLECTION_VIEWER_FACTORY = ( ) =>
7030 new BehaviorSubject < ListRange > ( { start : 0 , end : 0 } ) ;
@@ -84,12 +44,10 @@ const SCROLL_SCHEDULER =
8444 */
8545@Directive ( {
8646 selector : 'cdk-table[virtualScroll], table[cdk-table][virtualScroll]' ,
87- exportAs : 'cdkVirtualScroll ' ,
47+ exportAs : 'cdkTableVirtualScroll ' ,
8848 providers : [
8949 { provide : _VIEW_REPEATER_STRATEGY , useClass : _RecycleViewRepeaterStrategy } ,
90- // The directive cannot provide itself as the sticky positions listener because it introduces
91- // a circular dependency. Use an intermediate listener as a proxy.
92- { provide : STICKY_POSITIONING_LISTENER , useClass : _PositioningListenerProxy } ,
50+ { provide : STICKY_POSITIONING_LISTENER , useExisting : CdkTableVirtualScroll } ,
9351 // Initially emit an empty range. The virtual scroll viewport will update the range after it is
9452 // initialized.
9553 {
@@ -141,9 +99,6 @@ export class CdkTableVirtualScroll<T>
14199 }
142100
143101 constructor ( ) {
144- const positioningListener = inject < _PositioningListenerProxy > ( STICKY_POSITIONING_LISTENER ) ;
145- positioningListener . setListener ( this ) ;
146-
147102 // Force the table to enable `fixedLayout` to prevent column widths from changing as the user
148103 // scrolls. This also enables caching in the table's sticky styler which reduces calls to
149104 // expensive DOM APIs, such as `getBoundingClientRect()`, and improves overall performance.
@@ -193,13 +148,9 @@ export class CdkTableVirtualScroll<T>
193148 return 0 ;
194149 }
195150
196- stickyColumnsUpdated ( update : StickyUpdate ) : void {
197- // no-op
198- }
151+ stickyColumnsUpdated ( ) : void { }
199152
200- stickyEndColumnsUpdated ( update : StickyUpdate ) : void {
201- // no-op
202- }
153+ stickyEndColumnsUpdated ( ) : void { }
203154
204155 stickyHeaderRowsUpdated ( update : StickyUpdate ) : void {
205156 this . _headerRowStickyUpdates . next ( update ) ;
0 commit comments