mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 10:33:30 +08:00
Fix reversing scroll direction not always behaving as expected
This commit is contained in:
parent
e651a87d1d
commit
e96e558728
@ -275,11 +275,22 @@ namespace osu.Game.Screens.Edit
|
||||
|
||||
protected override bool OnScroll(ScrollEvent e)
|
||||
{
|
||||
scrollAccumulation += (e.ScrollDelta.X + e.ScrollDelta.Y) * (e.IsPrecise ? 0.1 : 1);
|
||||
const double precision = 1;
|
||||
|
||||
const int precision = 1;
|
||||
double scrollComponent = e.ScrollDelta.X + e.ScrollDelta.Y;
|
||||
|
||||
while (Math.Abs(scrollAccumulation) > precision)
|
||||
double scrollDirection = Math.Sign(scrollComponent);
|
||||
|
||||
// this is a special case to handle the "pivot" scenario.
|
||||
// if we are precise scrolling in one direction then change our mind and scroll backwards,
|
||||
// the existing accumulation should be applied in the inverse direction to maintain responsiveness.
|
||||
if (Math.Sign(scrollAccumulation) != scrollDirection)
|
||||
scrollAccumulation = scrollDirection * (precision - Math.Abs(scrollAccumulation));
|
||||
|
||||
scrollAccumulation += scrollComponent * (e.IsPrecise ? 0.1 : 1);
|
||||
|
||||
// because we are doing snapped seeking, we need to add up precise scrolls until they accumulate to an arbitrary cut-off.
|
||||
while (Math.Abs(scrollAccumulation) >= precision)
|
||||
{
|
||||
if (scrollAccumulation > 0)
|
||||
seek(e, -1);
|
||||
|
@ -120,7 +120,7 @@ namespace osu.Game.Screens.Edit
|
||||
|
||||
// Due to the rounding above, we may end up on the current beat. This will effectively cause 0 seeking to happen, but we don't want this.
|
||||
// Instead, we'll go to the next beat in the direction when this is the case
|
||||
if (Precision.AlmostEquals(current, seekTime))
|
||||
if (Precision.AlmostEquals(current, seekTime, 1))
|
||||
{
|
||||
closestBeat += direction > 0 ? 1 : -1;
|
||||
seekTime = timingPoint.Time + closestBeat * seekAmount;
|
||||
|
Loading…
Reference in New Issue
Block a user