summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2020-06-04 10:07:55 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2020-06-04 10:07:55 +0200
commit98438b94388e19e68a8bb2a9673b29966d260814 (patch)
treed9b16eda65bb6c31f4a4b9ae07ac4e063d0755d4
parenta49f215cfb4570bcc7c38458ce4f5c73c37dfb8a (diff)
downloadgdx-boardgame-98438b94388e19e68a8bb2a9673b29966d260814.zip
gdx-boardgame-98438b94388e19e68a8bb2a9673b29966d260814.tar.gz
Scrollable : fix ty
-rw-r--r--core/src/ch/asynk/gdx/boardgame/ui/Scrollable.java9
-rw-r--r--test/src/ch/asynk/gdx/boardgame/test/UiScreen.java2
2 files changed, 5 insertions, 6 deletions
diff --git a/core/src/ch/asynk/gdx/boardgame/ui/Scrollable.java b/core/src/ch/asynk/gdx/boardgame/ui/Scrollable.java
index 14d22b7..3aab8b0 100644
--- a/core/src/ch/asynk/gdx/boardgame/ui/Scrollable.java
+++ b/core/src/ch/asynk/gdx/boardgame/ui/Scrollable.java
@@ -67,14 +67,13 @@ public class Scrollable extends Element
float tx = 0;
float ty = 0;
if (vScroll) {
- if (dy > 0 && child.rect.y < innerRect.y) {
- ty = Math.min(dy, innerRect.y - child.rect.y);
- }
- else if (dy < 0) {
+ if (dy < 0 && child.rect.y < innerRect.y) {
+ ty = Math.min(-dy, innerRect.y - child.rect.y);
+ } else if (dy > 0) {
float cly = innerRect.y + innerRect.height;
float chy = child.rect.y + child.rect.height;
if (chy > cly)
- ty = Math.max(dy, cly - chy);
+ ty = -Math.min(dy, chy - cly);
}
}
if (hScroll) {
diff --git a/test/src/ch/asynk/gdx/boardgame/test/UiScreen.java b/test/src/ch/asynk/gdx/boardgame/test/UiScreen.java
index 319ffab..ce78892 100644
--- a/test/src/ch/asynk/gdx/boardgame/test/UiScreen.java
+++ b/test/src/ch/asynk/gdx/boardgame/test/UiScreen.java
@@ -211,7 +211,7 @@ public class UiScreen extends AbstractScreen
{
hudTouch.set(dragPos.x, dragPos.y, 0);
camera.unproject(hudTouch);
- root.drag(hudTouch.x, hudTouch.y, -dx, dy);
+ root.drag(hudTouch.x, hudTouch.y, dx, dy);
}
}