snapTarget method
Returns a snap target if a pointer is near a split divider.
Implementation
PaneSnapTarget? snapTarget({
required int x,
required int y,
required int width,
required int height,
}) {
if (!isValid) return null;
if (width <= 0 || height <= 0) return null;
final currentLayout = layout(width: width, height: height);
for (final handle in currentLayout.splits.values) {
if (handle.direction == PaneSplitDirection.vertical) {
if (_isWithinHorizontalSnap(x, handle.boundaryX, snapThreshold) &&
y >= handle.y &&
y < handle.y + handle.height) {
return PaneSnapTarget(
splitId: handle.splitId,
direction: handle.direction,
alignment: x <= handle.boundaryX
? PaneSnapAlignment.before
: PaneSnapAlignment.after,
);
}
} else {
if (_isWithinHorizontalSnap(y, handle.boundaryY, snapThreshold) &&
x >= handle.x &&
x < handle.x + handle.width) {
return PaneSnapTarget(
splitId: handle.splitId,
direction: handle.direction,
alignment: y <= handle.boundaryY
? PaneSnapAlignment.before
: PaneSnapAlignment.after,
);
}
}
}
return null;
}