Skip to content

Commit 0721743

Browse files
committed
ux: convert vertical scrolling to horizontal scrolling for launcher tabs
Signed-off-by: leo <longshuang@msn.cn>
1 parent d1f1353 commit 0721743

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

‎src/Views/LauncherTabBar.axaml.cs‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,20 @@ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs chang
171171

172172
private void ScrollTabs(object _, PointerWheelEventArgs e)
173173
{
174-
if (e.KeyModifiers.HasFlag(KeyModifiers.Shift))
174+
if (Math.Abs(e.Delta.X) < Math.Abs(e.Delta.Y))
175175
{
176-
if (e.Delta.Y < 0)
177-
LauncherTabsScroller.Offset += _scrollStep;
178-
else if (e.Delta.Y > 0)
179-
LauncherTabsScroller.Offset -= _scrollStep;
176+
var x = LauncherTabsScroller.Offset.X;
177+
var extent = LauncherTabsScroller.Extent.Width;
178+
var viewport = LauncherTabsScroller.Viewport.Width;
179+
var delta = e.Delta.Y;
180+
181+
if (extent > viewport)
182+
{
183+
x += -delta * 64; // Use the same logic with vertical scrolling in `ScrollContentPresenter`
184+
x = Math.Min(Math.Max(x, 0), extent - viewport);
185+
}
186+
187+
LauncherTabsScroller.Offset = new Vector(x, 0);
180188
e.Handled = true;
181189
}
182190
}

0 commit comments

Comments
 (0)