From 448eeefc42044d1ac4af3e931848dac826518d17 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Sat, 8 Jun 2024 15:56:20 +0000 Subject: [PATCH] Limit overshoot distance in scroller --- launcher/helper.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/launcher/helper.cpp b/launcher/helper.cpp index 3255a610f..931f3435d 100644 --- a/launcher/helper.cpp +++ b/launcher/helper.cpp @@ -15,6 +15,19 @@ #include #include +#ifdef VCMI_MOBILE +static QScrollerProperties generateScrollerProperties() +{ + QScrollerProperties result; + + result.setScrollMetric(QScrollerProperties::OvershootDragResistanceFactor, 0.25); + result.setScrollMetric(QScrollerProperties::OvershootDragDistanceFactor, 0.25); + result.setScrollMetric(QScrollerProperties::HorizontalOvershootPolicy, QScrollerProperties::OvershootAlwaysOff); + + return result; +} +#endif + namespace Helper { void loadSettings() @@ -26,6 +39,8 @@ void enableScrollBySwiping(QObject * scrollTarget) { #ifdef VCMI_MOBILE QScroller::grabGesture(scrollTarget, QScroller::LeftMouseButtonGesture); + QScroller * scroller = QScroller::scroller(scrollTarget); + scroller->setScrollerProperties(generateScrollerProperties()); #endif } }