mirror of
https://github.com/haexhub/haex-hub.git
synced 2025-12-16 14:10:52 +01:00
Fix icon drag bounds on x-axis
Prevent icons from being dragged beyond viewport boundaries on the x-axis. Icons are now clamped to valid positions during drag, not just on drop. - Added viewport bounds checking for both x and y axes during drag - Icons stay within [0, viewport.width - iconWidth] horizontally - Icons stay within [0, viewport.height - iconHeight] vertically - Eliminates snap-back behavior when dragging near edges Bump version to 0.1.8
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "haex-hub",
|
||||
"private": true,
|
||||
"version": "0.1.7",
|
||||
"version": "0.1.8",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "nuxt build",
|
||||
|
||||
@ -196,9 +196,12 @@ const handlePointerMove = (e: PointerEvent) => {
|
||||
const newX = e.clientX - parentRect.left - offsetX.value
|
||||
const newY = e.clientY - parentRect.top - offsetY.value
|
||||
|
||||
// Clamp y position to minimum 0 (parent is already below header)
|
||||
x.value = newX
|
||||
y.value = Math.max(0, newY)
|
||||
// Clamp position to viewport bounds during drag
|
||||
const maxX = viewportSize ? Math.max(0, viewportSize.width.value - iconWidth.value) : Number.MAX_SAFE_INTEGER
|
||||
const maxY = viewportSize ? Math.max(0, viewportSize.height.value - iconHeight.value) : Number.MAX_SAFE_INTEGER
|
||||
|
||||
x.value = Math.max(0, Math.min(maxX, newX))
|
||||
y.value = Math.max(0, Math.min(maxY, newY))
|
||||
|
||||
// Emit current position during drag
|
||||
emit('dragging', props.id, x.value, y.value)
|
||||
|
||||
Reference in New Issue
Block a user