Fix scrolling to message in pinned section.
This commit is contained in:
parent
cd5cad72bd
commit
ebbe75ac0a
|
@ -389,13 +389,13 @@ std::optional<int> ListWidget::scrollTopForView(
|
|||
return top - std::max((available - height) / 2, 0);
|
||||
}
|
||||
|
||||
void ListWidget::animatedScrollTo(
|
||||
void ListWidget::scrollTo(
|
||||
int scrollTop,
|
||||
Data::MessagePosition attachPosition,
|
||||
int delta,
|
||||
AnimatedScroll type) {
|
||||
_scrollToAnimation.stop();
|
||||
if (!delta || _items.empty()) {
|
||||
if (!delta || _items.empty() || type == AnimatedScroll::None) {
|
||||
_delegate->listScrollTo(scrollTop);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -168,8 +168,9 @@ public:
|
|||
enum class AnimatedScroll {
|
||||
Full,
|
||||
Part,
|
||||
None,
|
||||
};
|
||||
void animatedScrollTo(
|
||||
void scrollTo(
|
||||
int scrollTop,
|
||||
Data::MessagePosition attachPosition,
|
||||
int delta,
|
||||
|
|
|
@ -178,7 +178,10 @@ void PinnedWidget::showAtPosition(
|
|||
|
||||
bool PinnedWidget::showAtPositionNow(
|
||||
Data::MessagePosition position,
|
||||
HistoryItem *originItem) {
|
||||
HistoryItem *originItem,
|
||||
anim::type animated) {
|
||||
using AnimatedScroll = HistoryView::ListWidget::AnimatedScroll;
|
||||
|
||||
const auto item = position.fullId
|
||||
? _history->owner().message(position.fullId)
|
||||
: nullptr;
|
||||
|
@ -189,13 +192,16 @@ bool PinnedWidget::showAtPositionNow(
|
|||
const auto fullDelta = (wanted - currentScrollTop);
|
||||
const auto limit = _scroll->height();
|
||||
const auto scrollDelta = snap(fullDelta, -limit, limit);
|
||||
_inner->animatedScrollTo(
|
||||
const auto type = (animated == anim::type::instant)
|
||||
? AnimatedScroll::None
|
||||
: (std::abs(fullDelta) > limit)
|
||||
? AnimatedScroll::Part
|
||||
: AnimatedScroll::Full;
|
||||
_inner->scrollTo(
|
||||
wanted,
|
||||
use,
|
||||
scrollDelta,
|
||||
(std::abs(fullDelta) > limit
|
||||
? HistoryView::ListWidget::AnimatedScroll::Part
|
||||
: HistoryView::ListWidget::AnimatedScroll::Full));
|
||||
type);
|
||||
if (use != Data::MaxMessagePosition
|
||||
&& use != Data::UnreadMessagePosition) {
|
||||
_inner->highlightMessage(use.fullId);
|
||||
|
@ -356,7 +362,7 @@ void PinnedWidget::restoreState(not_null<PinnedMemento*> memento) {
|
|||
.date = TimeId(0),
|
||||
};
|
||||
_inner->showAroundPosition(position, [=] {
|
||||
return showAtPositionNow(position, nullptr);
|
||||
return showAtPositionNow(position, nullptr, anim::type::instant);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,7 +117,8 @@ private:
|
|||
HistoryItem *originItem = nullptr);
|
||||
bool showAtPositionNow(
|
||||
Data::MessagePosition position,
|
||||
HistoryItem *originItem);
|
||||
HistoryItem *originItem,
|
||||
anim::type animated = anim::type::normal);
|
||||
|
||||
void setupScrollDownButton();
|
||||
void scrollDownClicked();
|
||||
|
|
|
@ -1169,7 +1169,9 @@ void RepliesWidget::showAtPosition(
|
|||
|
||||
bool RepliesWidget::showAtPositionNow(
|
||||
Data::MessagePosition position,
|
||||
HistoryItem *originItem) {
|
||||
HistoryItem *originItem,
|
||||
anim::type animated) {
|
||||
using AnimatedScroll = HistoryView::ListWidget::AnimatedScroll;
|
||||
const auto item = position.fullId
|
||||
? _history->owner().message(position.fullId)
|
||||
: nullptr;
|
||||
|
@ -1183,13 +1185,16 @@ bool RepliesWidget::showAtPositionNow(
|
|||
const auto fullDelta = (wanted - currentScrollTop);
|
||||
const auto limit = _scroll->height();
|
||||
const auto scrollDelta = snap(fullDelta, -limit, limit);
|
||||
_inner->animatedScrollTo(
|
||||
const auto type = (animated == anim::type::instant)
|
||||
? AnimatedScroll::None
|
||||
: (std::abs(fullDelta) > limit)
|
||||
? AnimatedScroll::Part
|
||||
: AnimatedScroll::Full;
|
||||
_inner->scrollTo(
|
||||
wanted,
|
||||
use,
|
||||
scrollDelta,
|
||||
(std::abs(fullDelta) > limit
|
||||
? HistoryView::ListWidget::AnimatedScroll::Part
|
||||
: HistoryView::ListWidget::AnimatedScroll::Full));
|
||||
type);
|
||||
if (use != Data::MaxMessagePosition
|
||||
&& use != Data::UnreadMessagePosition) {
|
||||
_inner->highlightMessage(use.fullId);
|
||||
|
|
|
@ -150,7 +150,8 @@ private:
|
|||
HistoryItem *originItem = nullptr);
|
||||
bool showAtPositionNow(
|
||||
Data::MessagePosition position,
|
||||
HistoryItem *originItem);
|
||||
HistoryItem *originItem,
|
||||
anim::type animated = anim::type::normal);
|
||||
void finishSending();
|
||||
|
||||
void setupComposeControls();
|
||||
|
|
|
@ -802,7 +802,7 @@ bool ScheduledWidget::showAtPositionNow(Data::MessagePosition position) {
|
|||
const auto fullDelta = (wanted - currentScrollTop);
|
||||
const auto limit = _scroll->height();
|
||||
const auto scrollDelta = snap(fullDelta, -limit, limit);
|
||||
_inner->animatedScrollTo(
|
||||
_inner->scrollTo(
|
||||
wanted,
|
||||
position,
|
||||
scrollDelta,
|
||||
|
|
Loading…
Reference in New Issue