summaryrefslogtreecommitdiff
path: root/src/ui/listwidget.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-04-21 14:22:01 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-04-21 14:22:01 +0300
commit2e7b41f2d20cee278514b84ccf131062a62b3fee (patch)
treeef12ed8bd50760678715209bc9cb3532cbb4df66 /src/ui/listwidget.c
parentb19d76bcb518287e63c6808c6dc1418d349f4ff7 (diff)
Touch: Stopping momentum scroll
When a widget runs out of scrollable area, stop any momentum scrolls.
Diffstat (limited to 'src/ui/listwidget.c')
-rw-r--r--src/ui/listwidget.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/ui/listwidget.c b/src/ui/listwidget.c
index f571bea5..8690f8e5 100644
--- a/src/ui/listwidget.c
+++ b/src/ui/listwidget.c
@@ -172,9 +172,13 @@ iBool scrollOffset_ListWidget(iListWidget *d, int offset) {
172 d->scrollY += offset; 172 d->scrollY += offset;
173 if (d->scrollY < 0) { 173 if (d->scrollY < 0) {
174 d->scrollY = 0; 174 d->scrollY = 0;
175 stopWidgetMomentum_Touch(as_Widget(d));
175 } 176 }
176 const int scrollMax = scrollMax_ListWidget_(d); 177 const int scrollMax = scrollMax_ListWidget_(d);
177 d->scrollY = iMin(d->scrollY, scrollMax); 178 if (d->scrollY >= scrollMax) {
179 d->scrollY = scrollMax;
180 stopWidgetMomentum_Touch(as_Widget(d));
181 }
178 d->noHoverWhileScrolling = iTrue; 182 d->noHoverWhileScrolling = iTrue;
179 if (oldScroll != d->scrollY) { 183 if (oldScroll != d->scrollY) {
180 if (d->hoverItem != iInvalidPos) { 184 if (d->hoverItem != iInvalidPos) {
@@ -310,7 +314,7 @@ static iBool processEvent_ListWidget_(iListWidget *d, const SDL_Event *ev) {
310 return iTrue; 314 return iTrue;
311 } 315 }
312 } 316 }
313 else if (ev->type == SDL_USEREVENT && ev->user.code == widgetTapBegins_UserEventCode) { 317 else if (ev->type == SDL_USEREVENT && ev->user.code == widgetTapBegins_UserEventCode) {
314 d->noHoverWhileScrolling = iFalse; 318 d->noHoverWhileScrolling = iFalse;
315 } 319 }
316 if (ev->type == SDL_MOUSEMOTION) { 320 if (ev->type == SDL_MOUSEMOTION) {