-
Notifications
You must be signed in to change notification settings - Fork 6.8k
virtual-scroll: add support for scrollToOffset
and scrollToIndex
#12272
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
CLA justification - I asked @amcdnl if its ok to take over from his PR, he said it was ok. |
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
Sad to see that not get included. Its relatively simple and adds a big value imo. Looks good otherwise. |
I wasn't part of the previous PR so I don't remember what it was about. What does the |
If the specified index is already in the viewport, it doesn't bother scrolling (if lazy were not specified it would scroll that element to the top of the viewport) |
To me it sounds like a very narrow use case. If we provide a method like |
Should be helpful in certain cases. |
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 aside from a last couple of nits, add merge-ready when ready.
for the lazy
thing, I agree that we should keep the API simpler for now and see how it goes once released
@@ -77,6 +77,13 @@ export class FixedSizeVirtualScrollStrategy implements VirtualScrollStrategy { | |||
/** @docs-private Implemented as part of VirtualScrollStrategy. */ | |||
onRenderedOffsetChanged() { /* no-op */ } | |||
|
|||
/** Scroll to the offset for the given index. */ | |||
scrollToIndex(index: number, behavior: ScrollBehavior) { |
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.
It should still have void
, though, since dgeni can't use the inferred types. Also missing @param
JsDocs
@@ -245,7 +246,28 @@ export class CdkVirtualScrollViewport implements OnInit, OnDestroy { | |||
} | |||
} | |||
|
|||
/** Sets the scroll offset on the viewport. */ | |||
/** Scrolls to the offset on the viewport. */ | |||
scrollToOffset(offset: number, behavior: ScrollBehavior = 'auto') { |
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 @param
JsDocs?
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the |
A Googler has manually verified that the CLAs look good. (Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.) |
…12272) Note: `scrollToIndex` currently does not work with the `AutoSizeVirtualScrollStrategy`. Support for this will be added in a future PR. This PR is based off #11498 by @amcdnl. I removed the `lazy` option from #11498 to avoid bloating the API. I'm not sure how common the use case is, and its relatively simple to implement on top using the current APIs.
Any update on |
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. |
Note:
scrollToIndex
currently does not work with theAutoSizeVirtualScrollStrategy
. Support for this will be added in a future PR.This PR is based off #11498 by @amcdnl. I removed the
lazy
option from #11498 to avoid bloating the API. I'm not sure how common the use case is, and its relatively simple to implement on top using the current APIs.