Skip to content

Commit bb17d31

Browse files
committed
Fix strange menu scrolling behavior on web
1 parent 5868cb1 commit bb17d31

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

source/funkin/ui/freeplay/FreeplayState.hx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1730,12 +1730,12 @@ class FreeplayState extends MusicBeatSubState
17301730

17311731
handleDirectionalInput(elapsed);
17321732

1733-
final wheelAmount:Float = #if !html5 FlxG.mouse.wheel #else FlxG.mouse.wheel / 8 #end;
1733+
final wheelAmount:Int = Std.int(FlxMath.bound(FlxG.mouse.wheel, -1, 1));
17341734

17351735
if (wheelAmount != 0)
17361736
{
17371737
dj?.onPlayerAction(); // dj?.resetAFKTimer();
1738-
changeSelection(-Math.round(wheelAmount));
1738+
changeSelection(-wheelAmount);
17391739
}
17401740

17411741
handleDifficultySwitch();

source/funkin/ui/story/StoryMenuState.hx

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import flixel.group.FlxGroup.FlxTypedGroup;
66
import flixel.text.FlxText;
77
import flixel.tweens.FlxEase;
88
import flixel.tweens.FlxTween;
9+
import flixel.math.FlxMath;
910
import flixel.util.FlxColor;
1011
import flixel.util.FlxTimer;
1112
import funkin.audio.FunkinSound;
@@ -372,21 +373,12 @@ class StoryMenuState extends MusicBeatState
372373
changeDifficulty(0);
373374
}
374375

375-
#if !html5
376-
if (FlxG.mouse.wheel != 0)
377-
{
378-
changeLevel(-Math.round(FlxG.mouse.wheel));
379-
}
380-
#else
381-
if (FlxG.mouse.wheel < 0)
382-
{
383-
changeLevel(-Math.round(FlxG.mouse.wheel / 8));
384-
}
385-
else if (FlxG.mouse.wheel > 0)
376+
final wheelAmount:Int = Std.int(FlxMath.bound(FlxG.mouse.wheel, -1, 1));
377+
378+
if (wheelAmount != 0)
386379
{
387-
changeLevel(-Math.round(FlxG.mouse.wheel / 8));
380+
changeLevel(-wheelAmount);
388381
}
389-
#end
390382

391383
// TODO: Querying UI_RIGHT_P (justPressed) after UI_RIGHT always returns false. Fix it!
392384
if (controls.UI_RIGHT_P #if FEATURE_TOUCH_CONTROLS

0 commit comments

Comments
 (0)