[escher] Scroll speed increase for long repetition in scrollable views.

Change-Id: Ie7671ced53da1a144068756f6b584dbb287f9e0e
This commit is contained in:
Hugo Saint-Vignes
2020-06-10 10:09:08 +02:00
committed by Émilie Feral
parent b60c67ff88
commit c9964e69c2

View File

@@ -12,28 +12,29 @@ ScrollableView::ScrollableView(Responder * parentResponder, View * view, ScrollV
bool ScrollableView::handleEvent(Ion::Events::Event event) {
KDPoint translation = KDPointZero;
KDCoordinate scrollStep = Ion::Events::longRepetitionScrollSpeed() * Metric::ScrollStep;
if (event == Ion::Events::Left) {
KDCoordinate movementToEdge = contentOffset().x();
if (movementToEdge > 0) {
translation = KDPoint(-std::min(Metric::ScrollStep, movementToEdge), 0);
translation = KDPoint(-std::min(scrollStep, movementToEdge), 0);
}
}
if (event == Ion::Events::Right) {
KDCoordinate movementToEdge = minimalSizeForOptimalDisplay().width() - bounds().width() - contentOffset().x();
if (movementToEdge > 0) {
translation = KDPoint(std::min(Metric::ScrollStep, movementToEdge), 0);
translation = KDPoint(std::min(scrollStep, movementToEdge), 0);
}
}
if (event == Ion::Events::Up) {
KDCoordinate movementToEdge = contentOffset().y();
if (movementToEdge > 0) {
translation = KDPoint(0, -std::min(Metric::ScrollStep, movementToEdge));
translation = KDPoint(0, -std::min(scrollStep, movementToEdge));
}
}
if (event == Ion::Events::Down) {
KDCoordinate movementToEdge = minimalSizeForOptimalDisplay().height() - bounds().height() - contentOffset().y();
if (movementToEdge > 0) {
translation = KDPoint(0, std::min(Metric::ScrollStep, movementToEdge));
translation = KDPoint(0, std::min(scrollStep, movementToEdge));
}
}
if (translation != KDPointZero) {