Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Flow.Launcher.Test/Flow.Launcher.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Flow.Launcher\Flow.Launcher.csproj" />
<ProjectReference Include="..\Plugins\Flow.Launcher.Plugin.Calculator\Flow.Launcher.Plugin.Calculator.csproj" />
<ProjectReference Include="..\Plugins\Flow.Launcher.Plugin.Explorer\Flow.Launcher.Plugin.Explorer.csproj" />
<ProjectReference Include="..\Plugins\Flow.Launcher.Plugin.Program\Flow.Launcher.Plugin.Program.csproj" />
Expand Down
36 changes: 36 additions & 0 deletions Flow.Launcher.Test/MouseWheelTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;
using System.Reflection;
using System.Windows;
using System.Windows.Input;
using System.Windows.Interop;
using Flow.Launcher.Resources.Controls;
using NUnit.Framework;

namespace Flow.Launcher.Test;

[TestFixture]
public class MouseWheelTest
{
[Test]
[RequiresThread(System.Threading.ApartmentState.STA)]
public void Test_Scroll_MouseWheel()
{
var scrollView = new CustomScrollViewerEx();

var mouseDevice = Mouse.PrimaryDevice;
var e = new MouseWheelEventArgs(mouseDevice, Environment.TickCount, 120)
{
RoutedEvent = UIElement.MouseWheelEvent
};

var onMouseWheelMethod = typeof(CustomScrollViewerEx).GetMethod(
"OnMouseWheel",
BindingFlags.NonPublic | BindingFlags.Instance
);

Assert.DoesNotThrow(() =>
{
onMouseWheelMethod.Invoke(scrollView, new object[] { e });
});
Comment thread
Jack251970 marked this conversation as resolved.
}
}
18 changes: 13 additions & 5 deletions Flow.Launcher/Resources/Controls/CustomScrollViewerEx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public class CustomScrollViewerEx : ScrollViewer
public CustomScrollViewerEx()
{
Loaded += OnLoaded;
var valueSource = DependencyPropertyHelper.GetValueSource(this, AutoPanningMode.IsEnabledProperty).BaseValueSource;
var valueSource = DependencyPropertyHelper.GetValueSource(this, AutoPanningMode.IsEnabledProperty)
.BaseValueSource;
if (valueSource == BaseValueSource.Default)
{
AutoPanningMode.SetIsEnabled(this, true);
Expand Down Expand Up @@ -45,9 +46,9 @@ public Orientation Orientation

public static readonly DependencyProperty AutoHideScrollBarsProperty =
ScrollViewerHelper.AutoHideScrollBarsProperty
.AddOwner(
typeof(CustomScrollViewerEx),
new PropertyMetadata(true, OnAutoHideScrollBarsChanged));
.AddOwner(
typeof(CustomScrollViewerEx),
new PropertyMetadata(true, OnAutoHideScrollBarsChanged));

public bool AutoHideScrollBars
{
Expand Down Expand Up @@ -96,6 +97,9 @@ protected override void OnMouseWheel(MouseWheelEventArgs e)
e.Handled = true;
}

if (ActualHeight <= 0)
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
Outdated
return;

var WheelChange = e.Delta * (ViewportHeight / 1.5) / ActualHeight;
var newOffset = LastVerticalLocation - WheelChange;

Expand Down Expand Up @@ -126,6 +130,9 @@ protected override void OnMouseWheel(MouseWheelEventArgs e)
e.Handled = true;
}

if (ActualHeight <= 0)
return;

var WheelChange = e.Delta * (ViewportWidth / 1.5) / ActualWidth;
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
var newOffset = LastHorizontalLocation - WheelChange;

Expand Down Expand Up @@ -196,7 +203,8 @@ public bool ChangeView(double? horizontalOffset, double? verticalOffset, float?
/// <param name="zoomFactor">A value between MinZoomFactor and MaxZoomFactor that specifies the required target ZoomFactor.</param>
/// <param name="disableAnimation"><see langword="true"/> to disable zoom/pan animations while changing the view; otherwise, <see langword="false"/>. The default is false.</param>
/// <returns><see langword="true"/> if the view is changed; otherwise, <see langword="false"/>.</returns>
public bool ChangeView(double? horizontalOffset, double? verticalOffset, float? zoomFactor, bool disableAnimation)
public bool ChangeView(double? horizontalOffset, double? verticalOffset, float? zoomFactor,
bool disableAnimation)
{
if (disableAnimation)
{
Expand Down
Loading