aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc
diff options
context:
space:
mode:
authorDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-06-11 15:23:24 +0200
committerDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-06-11 15:23:24 +0200
commitcf240685916b3d19b66ba1493aba2d9f9a07d151 (patch)
tree33b909007c9574a93d78ba5f2175f5e4f63d4ff9 /src/main/java/cc
parent47d0397a20b6065678cc597dc09d1bc3d05b8101 (diff)
downloadOneConfig-cf240685916b3d19b66ba1493aba2d9f9a07d151.tar.gz
OneConfig-cf240685916b3d19b66ba1493aba2d9f9a07d151.tar.bz2
OneConfig-cf240685916b3d19b66ba1493aba2d9f9a07d151.zip
fix scrolling problems
Diffstat (limited to 'src/main/java/cc')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java b/src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java
index 882289d..d884814 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java
@@ -69,23 +69,24 @@ public abstract class Page {
}
ScissorManager.resetScissor(vg, scissor);
- if(!(scrollBarLength > 727f)) {
+ if (!(scrollBarLength > 727f)) {
final float scrollBarY = (scroll / maxScroll) * 720f;
final boolean isMouseDown = Mouse.isButtonDown(0);
- final boolean scrollHover = InputUtils.isAreaHovered(x + 1042, (int) (y - scrollBarY), 12, (int) scrollBarLength) || (System.currentTimeMillis() - scrollTime < 1000);
- final boolean hovered = scrollHover && Mouse.isButtonDown(0);
- if (hovered && isMouseDown && !mouseWasDown) {
+ final boolean scrollHover = InputUtils.isAreaHovered(x + 1042, (int) (y - scrollBarY), 12, (int) scrollBarLength);
+ final boolean scrollTimePeriod = (System.currentTimeMillis() - scrollTime < 1000);
+ final boolean hovered = (scrollHover || scrollTimePeriod) && Mouse.isButtonDown(0);
+ if (scrollHover && isMouseDown && !mouseWasDown) {
yStart = InputUtils.mouseY();
dragging = true;
}
mouseWasDown = isMouseDown;
- if(dragging) {
+ if (dragging) {
scrollTarget = -(InputUtils.mouseY() - yStart) * maxScroll / 728f;
if (scrollTarget > 0f) scrollTarget = 0f;
else if (scrollTarget < -maxScroll + 728) scrollTarget = -maxScroll + 728;
scrollAnimation = new EaseOutQuad(150, scroll, scrollTarget, false);
}
- RenderManager.drawRoundedRect(vg, x + 1044, y - scrollBarY, 8, scrollBarLength, colorAnimation.getColor(scrollHover, dragging), 4f);
+ RenderManager.drawRoundedRect(vg, x + 1044, y - scrollBarY, 8, scrollBarLength, colorAnimation.getColor(scrollHover || scrollTimePeriod, dragging), 4f);
}
}