-
Notifications
You must be signed in to change notification settings - Fork 6.8k
virtual-scroll: add support for user-provided content wrapper #12183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -33,6 +35,15 @@ function rangesEqual(r1: ListRange, r2: ListRange): boolean { | |||
} | |||
|
|||
|
|||
@Directive({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add JsDoc class description?
|
||
/** The raw string version of the rendered content transform. */ | ||
private _rawRenderedContentTransform: string; | ||
/** The the rendered content transform. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This description just echoes the name now- expand to describe what it's for?
@@ -1,11 +1,14 @@ | |||
<!-- Place the ng-content in a template that we can conditionally render in different places. --> | |||
<ng-template #rawContent><ng-content></ng-content></ng-template> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per offline discussion, we can change this to just use straight <ng-content>
with a selector for [cdkVirtualScrollContent]
position: absolute; | ||
top: 0; | ||
left: 0; | ||
will-change: contents, transform; | ||
} | ||
|
||
.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper { | ||
.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this selector and the one below be nested under the .cdk-virtual-scroll-orientation-
?
@ViewChild(CdkVirtualScrollContent, {read: ElementRef}) _viewContentWrapper: ElementRef; | ||
|
||
/** The element in the viewport's content that wraps the rendered content. */ | ||
@ContentChild(CdkVirtualScrollContent, {read: ElementRef}) _contentContentWrapper: ElementRef; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type the ElementRef
here to ElementRef<HTMLElement>
for better type safety.
@@ -107,8 +120,9 @@ export class CdkVirtualScrollViewport implements OnInit, OnDestroy { | |||
/** A list of functions to run after the next change detection cycle. */ | |||
private _runAfterChangeDetection: Function[] = []; | |||
|
|||
constructor(public elementRef: ElementRef, private _changeDetectorRef: ChangeDetectorRef, | |||
private _ngZone: NgZone, private _sanitizer: DomSanitizer, | |||
constructor(public elementRef: ElementRef, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also stronger typing for the ElementRef
here.
FYI, I'm going to change some things around. I think the attribute selector isn't actually necessary, users can just place the whole |
d6d2830
to
209b578
Compare
Ok, changed it to suggest wrapping the entire table or list instead. This PR includes changes from #12181 so marking it blocked until that goes in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -16,10 +16,48 @@ cdk-virtual-scroll-viewport { | |||
|
|||
.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper { | |||
bottom: 0; | |||
|
|||
& > dl, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a comment that explains why this block of styles exists?
} | ||
|
||
.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper { | ||
right: 0; | ||
|
||
& > dl, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this block be captured in a mixin instead of repeating it?
private _rawRenderedContentTransform: string; | ||
/** | ||
* The the rendered content transform, used to move the rendered portion of the content to the | ||
* correct place in the viewport. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about
The CSS transform applied to the rendered subset of items so that they
appear within the bounds of the visible viewport
can be placed inside. To enable virtual scrolling over these type of elements, place the elements in | ||
their proper parent, and then wrap the whole thing in a `cdk-virtual-scroll-viewport`. Be careful | ||
that the parent does not introduce additional space (e.g. via `margin` or `padding`) as it may | ||
interfere with the scrolling. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"may interfere" -> "will interfere"?
comments addressed, PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@mmalerba It looks like this has lint errors with the latest push. |
whoops, should be fixed now |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
fixes #10118