Replaced dependence from scroll events in flexible scroll with custom.
This commit is contained in:
@@ -66,7 +66,7 @@ void FlexibleScrollHelper::setupScrollAnimation() {
|
||||
_scrollTopFrom,
|
||||
_scrollTopTo,
|
||||
std::clamp(eased, 0., 1.));
|
||||
_scroll->scrollToY(scrollCurrent);
|
||||
scrollToY(scrollCurrent);
|
||||
_lastScrollApplied = scrollCurrent;
|
||||
if (progress >= 1) {
|
||||
clearScrollState();
|
||||
@@ -122,7 +122,7 @@ void FlexibleScrollHelper::setupScrollHandling() {
|
||||
: -1);
|
||||
{
|
||||
_applyingFakeScrollState = true;
|
||||
_scroll->scrollToY(previousValue);
|
||||
scrollToY(previousValue);
|
||||
_applyingFakeScrollState = false;
|
||||
}
|
||||
if (_scrollAnimation.animating()
|
||||
@@ -248,7 +248,8 @@ void FlexibleScrollHelper::setupScrollHandlingWithFilter() {
|
||||
const auto wheel = static_cast<QWheelEvent*>(e.get());
|
||||
const auto delta = wheel->angleDelta().y();
|
||||
if (std::abs(delta) != 120) {
|
||||
return base::EventFilterResult::Continue;
|
||||
scrollToY(_scroll->scrollTop() - delta);
|
||||
return base::EventFilterResult::Cancel;
|
||||
}
|
||||
const auto actualTop = _scroll->scrollTop();
|
||||
const auto animationActive = _scrollAnimation.animating()
|
||||
@@ -329,13 +330,8 @@ void FlexibleScrollHelper::setupScrollHandlingWithFilter() {
|
||||
return base::EventFilterResult::Cancel;
|
||||
}, _filterLifetime);
|
||||
|
||||
_scroll->scrollTopValue(
|
||||
) | rpl::start_with_next([=](int top) {
|
||||
const auto current = heightDiff() - top;
|
||||
_inner->moveToLeft(0, std::min(0, current));
|
||||
_pinnedToTop->resize(
|
||||
_pinnedToTop->width(),
|
||||
std::max(current + _pinnedToTop->minimumHeight(), 0));
|
||||
_scroll->scrollTopValue() | rpl::start_with_next([=](int top) {
|
||||
applyScrollToPinnedLayout(top);
|
||||
}, _inner->lifetime());
|
||||
|
||||
_data.fillerWidthValue.events(
|
||||
@@ -350,4 +346,21 @@ void FlexibleScrollHelper::setupScrollHandlingWithFilter() {
|
||||
}));
|
||||
}
|
||||
|
||||
void FlexibleScrollHelper::scrollToY(int scrollCurrent) {
|
||||
applyScrollToPinnedLayout(scrollCurrent);
|
||||
_scroll->scrollToY(scrollCurrent);
|
||||
}
|
||||
|
||||
void FlexibleScrollHelper::applyScrollToPinnedLayout(int scrollCurrent) {
|
||||
const auto top = std::min(scrollCurrent, _scroll->scrollTopMax());
|
||||
const auto minimumHeight = _pinnedToTop->minimumHeight();
|
||||
const auto current = _pinnedToTop->maximumHeight()
|
||||
- minimumHeight
|
||||
- top;
|
||||
_inner->moveToLeft(0, std::min(0, current));
|
||||
_pinnedToTop->resize(
|
||||
_pinnedToTop->width(),
|
||||
std::max(current + minimumHeight, 0));
|
||||
}
|
||||
|
||||
} // namespace Info
|
||||
@@ -35,6 +35,8 @@ private:
|
||||
void setupScrollAnimation();
|
||||
void setupScrollHandling();
|
||||
void setupScrollHandlingWithFilter();
|
||||
void scrollToY(int value);
|
||||
void applyScrollToPinnedLayout(int scrollCurrent);
|
||||
|
||||
const not_null<Ui::ScrollArea*> _scroll;
|
||||
const not_null<Ui::RpWidget*> _inner;
|
||||
|
||||
Reference in New Issue
Block a user