C
C
Coder3212018-04-06 16:09:03
Angular
Coder321, 2018-04-06 16:09:03

Adding elements to ngFor without changing the scrollbar?

There is a page on which an array of calendars is rendered. Something like this 5ac770de587d9619752334.png, when scrolling up, I need to add the previous year to the array, and when scrolling down, the next one, but when adding, the focus should remain on the last year, that is, if the last year is 2019 when scrolling up, then 2018 should be added, and the focus should remain on 2019. But I haven’t figured out how to do this yet. If you splice after rendering to the desired year, then it turns out not very beautiful.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Mazhekin, 2018-04-06
@mazhekin

I did a similar task on the first Angular, it was a chat, and when scrolling up, I had to load the messages at the top and stay where I was. Scrolling after rendering is the only way I could think of, visually it turned out fine, there are no blinks, but I could do this with a custom scrollbar ( https://github.com/idiotWu/angular-smooth-scrollbar)
and I had to write my own ScrollbarCommander class. Which remembered the position before loading and in the render event after the last element, scrolled and restored the current scroll position.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question