fix(dock): address reviewer feedback on drag state and boundary tests
This commit is contained in:
@@ -3,7 +3,7 @@ namespace Ghost.Editor.Core.Controls.Internal.Docking;
|
||||
/// <summary>
|
||||
/// Defines the possible dock positions for a drop operation.
|
||||
/// </summary>
|
||||
public enum DockPosition
|
||||
internal enum DockPosition
|
||||
{
|
||||
Center,
|
||||
Top,
|
||||
@@ -16,7 +16,7 @@ public enum DockPosition
|
||||
/// <summary>
|
||||
/// Helper class for docking-related calculations.
|
||||
/// </summary>
|
||||
public static class DockMath
|
||||
internal static class DockMath
|
||||
{
|
||||
/// <summary>
|
||||
/// Calculates the dock position based on the relative position within a target element.
|
||||
@@ -24,6 +24,12 @@ public static class DockMath
|
||||
/// </summary>
|
||||
public static DockPosition CalculateDockPosition(double width, double height, double x, double y, double threshold)
|
||||
{
|
||||
// Guard against invalid inputs
|
||||
if (width <= 0 || height <= 0) return DockPosition.None;
|
||||
|
||||
// Clamp threshold to valid range [0, 0.5]
|
||||
threshold = Math.Max(0, Math.Min(0.5, threshold));
|
||||
|
||||
if (x < width * threshold) return DockPosition.Left;
|
||||
if (x > width * (1 - threshold)) return DockPosition.Right;
|
||||
if (y < height * threshold) return DockPosition.Top;
|
||||
|
||||
Reference in New Issue
Block a user