Browse Source
Use tap size as default size for scrolling start. reset IsGestureRecognitionSkipped when pointer is released (#15524 )
* use tap size as default size for scrolling start. reset IsGestureRecognitionSkipped when pointer is released
* use static default constant for scroll distance
* fix typo
pull/15562/head
Emmanuel Hansen
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with
10 additions and
4 deletions
src/Avalonia.Base/Input/GestureRecognizers/ScrollGestureRecognizer.cs
src/Avalonia.Base/Input/MouseDevice.cs
src/Avalonia.Base/Input/PenDevice.cs
src/Avalonia.Base/Input/TouchDevice.cs
tests/Avalonia.UnitTests/TouchTestHelper.cs
@ -1,5 +1,6 @@
using System ;
using System.Diagnostics ;
using Avalonia.Platform ;
using Avalonia.Threading ;
namespace Avalonia.Input.GestureRecognizers
@ -13,7 +14,8 @@ namespace Avalonia.Input.GestureRecognizers
private bool _ canHorizontallyScroll ;
private bool _ canVerticallyScroll ;
private bool _ isScrollInertiaEnabled ;
private int _ scrollStartDistance = 3 0 ;
private readonly static int s_defaultScrollStartDistance = ( int ) ( ( AvaloniaLocator . Current ? . GetService < IPlatformSettings > ( ) ? . GetTapSize ( PointerType . Touch ) . Height ? ? 1 0 ) / 2 ) ;
private int _ scrollStartDistance = s_defaultScrollStartDistance ;
private bool _ scrolling ;
private Point _ trackedRootPoint ;
@ -54,7 +56,7 @@ namespace Avalonia.Input.GestureRecognizers
public static readonly DirectProperty < ScrollGestureRecognizer , int > ScrollStartDistanceProperty =
AvaloniaProperty . RegisterDirect < ScrollGestureRecognizer , int > ( nameof ( ScrollStartDistance ) ,
o = > o . ScrollStartDistance , ( o , v ) = > o . ScrollStartDistance = v ,
unsetValue : 3 0 ) ;
unsetValue : s_defaultScrollStartDistance ) ;
/// <summary>
/// Gets or sets a value indicating whether the content can be scrolled horizontally.
@ -205,6 +205,7 @@ namespace Avalonia.Input
{
_ pointer . Capture ( null ) ;
_ pointer . CaptureGestureRecognizer ( null ) ;
_ pointer . IsGestureRecognitionSkipped = false ;
_l astMouseDownButton = default ;
}
return e . Handled ;
@ -167,6 +167,7 @@ namespace Avalonia.Input
{
pointer . Capture ( null ) ;
pointer . CaptureGestureRecognizer ( null ) ;
pointer . IsGestureRecognitionSkipped = false ;
_l astMouseDownButton = default ;
}
@ -119,6 +119,8 @@ namespace Avalonia.Input
{
pointer ? . Capture ( null ) ;
pointer ? . CaptureGestureRecognizer ( null ) ;
if ( pointer ! = null )
pointer . IsGestureRecognitionSkipped = false ;
}
}
@ -49,8 +49,7 @@ namespace Avalonia.UnitTests
else
source . RaiseEvent ( e ) ;
_ pointer . Capture ( null ) ;
_ pointer . CaptureGestureRecognizer ( null ) ;
Cancel ( ) ;
}
public void Tap ( Interactive target , Point position = default , KeyModifiers modifiers = default )
@ -66,6 +65,7 @@ namespace Avalonia.UnitTests
{
_ pointer . Capture ( null ) ;
_ pointer . CaptureGestureRecognizer ( null ) ;
_ pointer . IsGestureRecognitionSkipped = false ;
}
}
}