allow slight overscrolling in optionsmenu

This commit is contained in:
yugecin 2017-01-29 16:23:52 +01:00
parent ac398bf2ad
commit 82bbb4299d
2 changed files with 23 additions and 9 deletions

View File

@ -61,6 +61,12 @@ public class KineticScrolling {
/** The speed multiplier (divides {@link #TIME_CONST}). */
private float speedMultiplier = 1f;
private boolean allowOverScroll;
public void setAllowOverScroll(boolean allowOverScroll) {
this.allowOverScroll = allowOverScroll;
}
/**
* Returns the current position.
* @return the position
@ -94,15 +100,25 @@ public class KineticScrolling {
target = position;
deltaPosition = 0;
}
if (allowOverScroll && pressed) {
return;
}
if (position > max) {
if (allowOverScroll) {
scrollToPosition(max);
} else {
amplitude = 0;
target = position = max;
}
if (position < min) {
} else if (position < min) {
if (allowOverScroll) {
scrollToPosition(min);
} else {
amplitude = 0;
target = position = min;
}
}
}
/**
* Scrolls to the position.

View File

@ -152,6 +152,7 @@ public class OptionsOverlay extends OverlayOpsuState {
listHoverIndex = -1;
searchField = new TextField(displayContainer, null, 0, 0, 0, 0);
scrollHandler = new KineticScrolling();
scrollHandler.setAllowOverScroll(true);
}
public void setListener(Listener listener) {
@ -326,9 +327,6 @@ public class OptionsOverlay extends OverlayOpsuState {
maxScrollOffset = 0;
}
scrollHandler.setMinMax(0f, maxScrollOffset);
if (scrollHandler.getIntPosition() > maxScrollOffset) {
scrollHandler.setPosition(maxScrollOffset);
}
}
private void renderOpenList(Graphics g) {