Open mak2xt opened 5 years ago
I'm not sure that this is what setRenderedContentOffset
is supposed to do. Maybe you're looking for scrollTo
?
Well, I want to show dates in the middle, and first date too. That's why I want scroll container to have start/end offset roughly half the height of the viewport. I'm already using scrollTo and it works perfect.
As a workaround, I can insert empty items on top and bottom but don't think that this a good solution. If you look at kendo implementation, they're kinda using the same content offset for centring.
@crisbeto any further comments on the issue?
I'm not super familiar with the design decisions behind virtual scrolling. @mmalerba would be a better person to pitch in here.
setRenderedContentOffset
is not meant to be used like this. It is only supposed to be called by the VirtualScrollStrategy
to make the scrolling appear seamless even as items are added and removed from the top
@mmalerba should this info be included in documentation because it's listed as a public method that seems like everyone is safe to use it?
Also, I will appreciate if you would give an advice on my problem. Thanks
Bug, feature request, or proposal:
Bug
What is the expected behavior?
Manually set offset by setRenderedContentOffset should not go back to 0 on scroll
What is the current behavior?
Scrolling resets offset which is perceived as a jump
What are the steps to reproduce?
https://stackblitz.com/edit/angular-egcu9t just click on "set offset to 200", see applied offset and then try to scroll
What is the use-case or motivation for changing an existing behavior?
I'm using this feature to create date picker similar to one in kendo(https://www.telerik.com/kendo-angular-ui/components/dateinputs/calendar/)
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
material 7.3.x
Is there anything else we should know?
Here's the responsible code: https://github.com/angular/material2/blob/master/src/cdk/scrolling/fixed-size-virtual-scroll.ts#L81 https://github.com/angular/material2/blob/master/src/cdk/scrolling/fixed-size-virtual-scroll.ts#L149
As I got from the debugger, newRange.start is always 0, and it's seen from line 81 the function executes on scroll