1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

Limit overshoot distance in scroller

This commit is contained in:
Ivan Savenko 2024-06-08 15:56:20 +00:00
parent a33a37b1a4
commit 448eeefc42

View File

@ -15,6 +15,19 @@
#include <QObject>
#include <QScroller>
#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
}
}