Skip to content

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

Merged
merged 3 commits into from
Jul 18, 2018

Conversation

mmalerba
Copy link
Contributor

fixes #10118

@mmalerba mmalerba requested review from amcdnl, jelbourn and crisbeto July 12, 2018 22:22
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jul 12, 2018
@@ -33,6 +35,15 @@ function rangesEqual(r1: ListRange, r2: ListRange): boolean {
}


@Directive({
Copy link
Member

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. */
Copy link
Member

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>
Copy link
Member

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 {
Copy link
Member

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;
Copy link
Member

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,
Copy link
Member

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.

@mmalerba
Copy link
Contributor Author

FYI, I'm going to change some things around. I think the attribute selector isn't actually necessary, users can just place the whole table, dl, etc inside the viewport and have it wrapped by the content wrapper

@mmalerba mmalerba force-pushed the vs-attr branch 2 times, most recently from d6d2830 to 209b578 Compare July 13, 2018 22:29
@mmalerba mmalerba added the blocked This issue is blocked by some external factor, such as a prerequisite PR label Jul 13, 2018
@mmalerba
Copy link
Contributor Author

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

Copy link
Contributor

@amcdnl amcdnl left a 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,
Copy link
Member

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,
Copy link
Member

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.
Copy link
Member

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"may interfere" -> "will interfere"?

@mmalerba
Copy link
Contributor Author

comments addressed, PTAL

@mmalerba mmalerba removed the blocked This issue is blocked by some external factor, such as a prerequisite PR label Jul 17, 2018
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mmalerba mmalerba added pr: lgtm action: merge The PR is ready for merge by the caretaker labels Jul 17, 2018
@ngbot
Copy link

ngbot bot commented Jul 17, 2018

I see that you just added the pr: merge ready label, but the following checks are still failing:
    failure status "ci/circleci: build" is failing
    failure status "continuous-integration/travis-ci/pr" is failing

If you want your PR to be merged, it has to pass all the CI checks.

If you can't get the PR to a green state due to flakes or broken master, please try rebasing to master and/or restarting the CI job. If that fails and you believe that the issue is not due to your change, please contact the caretaker and ask for help.

@josephperrott
Copy link
Member

@mmalerba It looks like this has lint errors with the latest push.

@josephperrott josephperrott removed the action: merge The PR is ready for merge by the caretaker label Jul 18, 2018
@mmalerba mmalerba added the action: merge The PR is ready for merge by the caretaker label Jul 18, 2018
@mmalerba
Copy link
Contributor Author

whoops, should be fixed now

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

virtual-scroll: support using elements that have parent requirements as virtual scroll items
6 participants