Skip to content

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

Merged
merged 14 commits into from
Jul 25, 2018

Conversation

mmalerba
Copy link
Contributor

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.

@mmalerba mmalerba requested review from amcdnl, jelbourn and crisbeto July 18, 2018 21:17
@mmalerba mmalerba requested a review from devversion as a code owner July 18, 2018 21:17
@googlebot googlebot added the cla: no PR author must sign Google's Contributor License Agreement: https://opensource.google.com/docs/cla label Jul 18, 2018
@mmalerba mmalerba added cla: yes PR author has agreed to Google's Contributor License Agreement and removed cla: no PR author must sign Google's Contributor License Agreement: https://opensource.google.com/docs/cla labels Jul 18, 2018
@mmalerba
Copy link
Contributor Author

CLA justification - I asked @amcdnl if its ok to take over from his PR, he said it was ok.

@mmalerba mmalerba added pr: merge safe target: patch This PR is targeted for the next patch release and removed pr: merge safe labels Jul 18, 2018
@googlebot googlebot added cla: no PR author must sign Google's Contributor License Agreement: https://opensource.google.com/docs/cla and removed cla: yes PR author has agreed to Google's Contributor License Agreement labels Jul 18, 2018
@mmalerba mmalerba added cla: yes PR author has agreed to Google's Contributor License Agreement and removed cla: no PR author must sign Google's Contributor License Agreement: https://opensource.google.com/docs/cla labels Jul 18, 2018
@googlebot googlebot added cla: no PR author must sign Google's Contributor License Agreement: https://opensource.google.com/docs/cla and removed cla: yes PR author has agreed to Google's Contributor License Agreement labels Jul 18, 2018
@angular angular deleted a comment from googlebot Jul 19, 2018
@angular angular deleted a comment from googlebot Jul 19, 2018
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

@amcdnl
Copy link
Contributor

amcdnl commented Jul 22, 2018

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.

Sad to see that not get included. Its relatively simple and adds a big value imo.

Looks good otherwise.

@mmalerba
Copy link
Contributor Author

@jelbourn @crisbeto what do you guys think of the lazy option? worth making part of the API?

@crisbeto
Copy link
Member

I wasn't part of the previous PR so I don't remember what it was about. What does the lazy option do?

@mmalerba
Copy link
Contributor Author

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)

@crisbeto
Copy link
Member

To me it sounds like a very narrow use case. If we provide a method like scrollToElement(index) then people should be able to do it themselves, if they need it.

@naveedahmed1
Copy link

Should be helpful in certain cases.

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

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

Choose a reason for hiding this comment

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

Add @param JsDocs?

@googlebot
Copy link

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 cla/google commit status will not change from this state. It's up to you to confirm consent of the commit author(s) and merge this pull request when appropriate.

@googlebot googlebot added cla: no PR author must sign Google's Contributor License Agreement: https://opensource.google.com/docs/cla and removed cla: yes PR author has agreed to Google's Contributor License Agreement labels Jul 24, 2018
@mmalerba mmalerba added cla: yes PR author has agreed to Google's Contributor License Agreement and removed cla: no PR author must sign Google's Contributor License Agreement: https://opensource.google.com/docs/cla labels Jul 24, 2018
@googlebot
Copy link

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.)

@mmalerba mmalerba added action: merge The PR is ready for merge by the caretaker pr: merge safe and removed pr: merge safe labels Jul 24, 2018
@mmalerba mmalerba merged commit 6a0b8f7 into angular:master Jul 25, 2018
mmalerba added a commit that referenced this pull request Jul 30, 2018
…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.
@naveedahmed1
Copy link

Any update on scrollToOffset and scrollToIndex support with AutoSizeVirtualScrollStrategy?

@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.

6 participants