Skip to content

Commit d48088d

Browse files
committed
wip: try using width/height for virtual scroll spacer sizing
1 parent c3eac17 commit d48088d

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

src/cdk/scrolling/virtual-scroll-viewport.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@
99
Spacer used to force the scrolling container to the correct size for the *total* number of items
1010
so that the scrollbar captures the size of the entire data set.
1111
-->
12-
<div class="cdk-virtual-scroll-spacer" [style.transform]="_totalContentSizeTransform"></div>
12+
<div class="cdk-virtual-scroll-spacer"
13+
[style.width]="orientation == 'horizontal' ? _totalContentSize + 'px' : ''"
14+
[style.height]="orientation == 'vertical' ? _totalContentSize + 'px' : ''"></div>

src/cdk/scrolling/virtual-scroll-viewport.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,10 @@ export class CdkVirtualScrollViewport extends CdkScrollable implements OnInit, O
8989
/** A stream that emits whenever the rendered range changes. */
9090
renderedRangeStream: Observable<ListRange> = this._renderedRangeSubject.asObservable();
9191

92-
/**
93-
* The transform used to scale the spacer to the same size as all content, including content that
94-
* is not currently rendered.
95-
*/
96-
_totalContentSizeTransform = '';
97-
9892
/**
9993
* The total size of all content (in pixels), including content that is not currently rendered.
10094
*/
101-
private _totalContentSize = 0;
95+
_totalContentSize = 0;
10296

10397
/**
10498
* The CSS transform applied to the rendered subset of items so that they appear within the bounds
@@ -238,8 +232,6 @@ export class CdkVirtualScrollViewport extends CdkScrollable implements OnInit, O
238232
setTotalContentSize(size: number) {
239233
if (this._totalContentSize !== size) {
240234
this._totalContentSize = size;
241-
const axis = this.orientation == 'horizontal' ? 'X' : 'Y';
242-
this._totalContentSizeTransform = `scale${axis}(${this._totalContentSize})`;
243235
this._markChangeDetectionNeeded();
244236
}
245237
}

0 commit comments

Comments
 (0)