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,13 +100,23 @@ public class KineticScrolling {
target = position;
deltaPosition = 0;
}
if (position > max) {
amplitude = 0;
target = position = max;
if (allowOverScroll && pressed) {
return;
}
if (position < min) {
amplitude = 0;
target = position = min;
if (position > max) {
if (allowOverScroll) {
scrollToPosition(max);
} else {
amplitude = 0;
target = position = max;
}
} else if (position < min) {
if (allowOverScroll) {
scrollToPosition(min);
} else {
amplitude = 0;
target = position = min;
}
}
}

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) {