2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-09-04 16:45:12 +00:00

Added scroll animation in dialogs list when it scrolls to top.

This commit is contained in:
23rd
2019-02-24 20:19:16 +03:00
committed by John Preston
parent c2ad765424
commit 32bc723745
2 changed files with 20 additions and 1 deletions

View File

@@ -333,7 +333,25 @@ void DialogsWidget::dialogsToUp() {
return;
}
if (_filter->getLastText().trimmed().isEmpty() && !_searchInChat) {
_scroll->scrollToY(0);
_scrollToAnimation.finish();
auto scrollTop = _scroll->scrollTop();
const auto scrollTo = 0;
const auto maxAnimatedDelta = _scroll->height();
if (scrollTo + maxAnimatedDelta < scrollTop) {
scrollTop = scrollTo + maxAnimatedDelta;
_scroll->scrollToY(scrollTop);
}
const auto scroll = [&] {
_scroll->scrollToY(qRound(_scrollToAnimation.current()));
};
_scrollToAnimation.start(
scroll,
scrollTop,
scrollTo,
st::slideDuration,
anim::sineInOut);
}
}