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);
}
}

View File

@ -199,6 +199,7 @@ private:
object_ptr<BottomButton> _loadMoreChats = { nullptr };
std::unique_ptr<Window::ConnectionState> _connecting;
Animation _scrollToAnimation;
Animation _a_show;
Window::SlideDirection _showDirection;
QPixmap _cacheUnder, _cacheOver;