Slide improved (keep the energy for multipages scroll)

This commit is contained in:
Bertrand Songis
2021-02-23 10:44:50 +01:00
parent d0b517e9f7
commit a4b8aafb36
2 changed files with 13 additions and 7 deletions
+12 -6
View File
@@ -64,14 +64,20 @@ void MainWindow::checkEvents()
}
}
else if (touchState.event == TE_SLIDE_END && slidingWindow) {
if (abs(touchState.lastDeltaX) >= 5 || abs(touchState.lastDeltaY) >= 5) {
onTouchSlide(touchState.x, touchState.y, touchState.startX, touchState.startY, touchState.lastDeltaX, touchState.lastDeltaY);
touchState.lastDeltaX = (touchState.lastDeltaX * 3) >> 2;
touchState.lastDeltaY = (touchState.lastDeltaY * 3) >> 2;
}
else {
if (touchState.lastDeltaX > SLIDE_SPEED_REDUCTION)
touchState.lastDeltaX -= SLIDE_SPEED_REDUCTION;
else if (touchState.lastDeltaX < -SLIDE_SPEED_REDUCTION)
touchState.lastDeltaX += SLIDE_SPEED_REDUCTION;
else
touchState.lastDeltaX = 0;
if (touchState.lastDeltaY > SLIDE_SPEED_REDUCTION)
touchState.lastDeltaY -= SLIDE_SPEED_REDUCTION;
else if (touchState.lastDeltaY < -SLIDE_SPEED_REDUCTION)
touchState.lastDeltaY += SLIDE_SPEED_REDUCTION;
else
touchState.lastDeltaY = 0;
if (touchState.lastDeltaX || touchState.lastDeltaY) {
onTouchSlide(touchState.x, touchState.y, touchState.startX, touchState.startY, touchState.lastDeltaX, touchState.lastDeltaY);
}
}
#endif
+1 -1
View File
@@ -346,7 +346,7 @@ void Window::checkEvents()
}
#if defined(HARDWARE_TOUCH)
if (touchState.event != TE_SLIDE) {
if (touchState.event != TE_SLIDE && touchState.lastDeltaX == 0 && touchState.lastDeltaY == 0) {
if (pageWidth) {
coord_t relativeScrollPosition = scrollPositionX % pageWidth;
if (relativeScrollPosition) {