Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ScrollContainer drift #763

Merged
merged 3 commits into from May 28, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 7 additions & 3 deletions osu.Framework/Graphics/Containers/ScrollContainer.cs
Expand Up @@ -224,12 +224,16 @@ protected override bool OnDrag(InputState state)

Vector2 childDelta = ToLocalSpace(state.Mouse.NativeState.Position) - ToLocalSpace(state.Mouse.NativeState.LastPosition);

float scrollOffset = -childDelta[scrollDim];
float clampedScrollOffset = clamp(target + scrollOffset) - clamp(target);

Trace.Assert(Precision.AlmostBigger(Math.Abs(scrollOffset), clampedScrollOffset * Math.Sign(scrollOffset)));

// If we are dragging past the extent of the scrollable area, half the offset
// such that the user can feel it.
if (target != clamp(target))
childDelta /= 2;
scrollOffset = clampedScrollOffset + (scrollOffset - clampedScrollOffset) / 2;

offset(-childDelta[scrollDim], false);
offset(scrollOffset, false);
return true;
}

Expand Down