Increase dragging dead zone (#7416)

This commit is contained in:
Leon Friedrich
2022-04-09 09:17:52 +12:00
committed by GitHub
parent 7900abb888
commit bec0b63dc1
4 changed files with 25 additions and 7 deletions

View File

@@ -21,14 +21,12 @@ namespace Content.Client.DragDrop
/// <typeparam name="T">thing being dragged and dropped</typeparam>
public sealed class DragDropHelper<T>
{
private const float DefaultDragDeadzone = 2f;
private readonly IInputManager _inputManager;
private readonly OnBeginDrag _onBeginDrag;
private readonly OnEndDrag _onEndDrag;
private readonly OnContinueDrag _onContinueDrag;
private readonly float _deadzone;
public float Deadzone = 2f;
/// <summary>
/// Convenience method, current mouse screen position as provided by inputmanager.
@@ -67,9 +65,8 @@ namespace Content.Client.DragDrop
/// <param name="deadzone">drag will be triggered when mouse leaves
/// this deadzone around the mousedown position</param>
public DragDropHelper(OnBeginDrag onBeginDrag, OnContinueDrag onContinueDrag,
OnEndDrag onEndDrag, float deadzone = DefaultDragDeadzone)
OnEndDrag onEndDrag)
{
_deadzone = deadzone;
_inputManager = IoCManager.Resolve<IInputManager>();
_onBeginDrag = onBeginDrag;
_onEndDrag = onEndDrag;
@@ -128,7 +125,7 @@ namespace Content.Client.DragDrop
case DragState.MouseDown:
{
var screenPos = _inputManager.MouseScreenPosition;
if ((_mouseDownScreenPos.Position - screenPos.Position).Length > _deadzone)
if ((_mouseDownScreenPos.Position - screenPos.Position).Length > Deadzone)
{
StartDragging();
}