You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
item not moved (to alt position) when colliding fails with an object #2819
When dragging, if the mouse position shifts downward by a certain distance after being pressed, a lagging effect occurs, making it look less "smooth." Attached is a video.
The first time when dragging, the mouse remains steady, and everything displays normally.
From the second time onward, start dragging with the mouse on the upper part of the element, then shift downward by a certain distance, and the result is not as smooth.
On the contrary, when starting to drag with the mouse on the lower part of the element and shifting upward during the drag, the process remains smooth.
pretty sure this is a dup of another bug. nothing to do with mouse lag. It's trying to collide with item below and failing to use alternative item to move when the first item fails to collide.
Also would have been helpful to modify the example to default to that layout issue, so I don't have to.
changed the title [-]When dragging, a slight mouse offset causes a "lagging" effect.[/-][+]item not moved when colliding fails with another object[/+]on Oct 15, 2024
changed the title [-]item not moved when colliding fails with another object[/-][+]item not moved (to alt space) when colliding fails with another object[/+]on Oct 15, 2024
changed the title [-]item not moved (to alt space) when colliding fails with another object[/-][+]item not moved (to alt position) when colliding fails with an object[/+]on Oct 15, 2024
I ran into the same issue on v12.4.2 with column: 48, cellHeight: 10, float: true. Traced it through the source — here's the root cause and a proposed fix.
Just a heads-up: Vibe-coded with Opus 4.6 using gridstack + svelte for UI/UX but relevant (Proposed fix is all Opus 4.6):
Root Cause
In gridstack-engine.js, the directionCollideCoverage() method has a hard-coded >50% directional coverage threshold (line ~186):
letoverMax=0.5;// need >50%
This is called from moveNode() (line ~970) only during active drag:
When the dragged widget overlaps a target by less than 50%, directionCollideCoverage returns undefined, and moveNode silently rejects the position update:
}else{needToMove=false;// we didn't cover >50% for a move, skip...}
Why it's asymmetric:
Dragging into empty space — no collision, collides.length === 0, so the position updates immediately at every cell increment
Dragging into an occupied cell — collision detected, but the 50% threshold blocks the move until you drag >50% of the target widget's height into its area
With small cellHeight (10–20px), this means you can drag smoothly upward into empty space, but dragging downward into an adjacent widget requires 50%+ of that widget's pixel height before anything happens — easily 100–300px of "dead zone."
Suggested Fix
Make the threshold configurable via GridStackOptions, defaulting to 0.5 for backward compatibility:
// types.ts — add to GridStackOptions/** Coverage threshold (0-1) for directional collision during drag. Default: 0.5 */
collisionCoverage?: number;
With small cellHeight (10–20px), this means you can drag smoothly upward into empty space, but dragging downward into an adjacent widget requires 50%+ of that widget's pixel height before anything happens — easily 100–300px of "dead zone."
it's not a dead zone, and yes you should cover the (larger) target widget by >50% before moving it out otherwise it wil always push it by 1 row and you could never push it past.
actually now that I write it down it should push and jump past if over 50% of larger object. so always move (if it can) by 50% row coverage.
Activity
adumesny commentedon Oct 15, 2024
pretty sure this is a dup of another bug. nothing to do with mouse lag. It's trying to collide with item below and failing to use alternative item to move when the first item fails to collide.
Also would have been helpful to modify the example to default to that layout issue, so I don't have to.
[-]When dragging, a slight mouse offset causes a "lagging" effect.[/-][+]item not moved when colliding fails with another object[/+][-]item not moved when colliding fails with another object[/-][+]item not moved (to alt space) when colliding fails with another object[/+][-]item not moved (to alt space) when colliding fails with another object[/-][+]item not moved (to alt position) when colliding fails with an object[/+]Hickays commentedon Oct 16, 2024
Oh, thanks for the reply. I apologize for my poor English and for not being able to accurately finding the repeat issue.
BrokeItSafely commentedon Mar 30, 2026
I ran into the same issue on v12.4.2 with
column: 48, cellHeight: 10, float: true. Traced it through the source — here's the root cause and a proposed fix.Just a heads-up: Vibe-coded with Opus 4.6 using gridstack + svelte for UI/UX but relevant (Proposed fix is all Opus 4.6):
Root Cause
In
gridstack-engine.js, thedirectionCollideCoverage()method has a hard-coded >50% directional coverage threshold (line ~186):This is called from
moveNode()(line ~970) only during active drag:When the dragged widget overlaps a target by less than 50%,
directionCollideCoveragereturnsundefined, andmoveNodesilently rejects the position update:Why it's asymmetric:
collides.length === 0, so the position updates immediately at every cell incrementWith small
cellHeight(10–20px), this means you can drag smoothly upward into empty space, but dragging downward into an adjacent widget requires 50%+ of that widget's pixel height before anything happens — easily 100–300px of "dead zone."Suggested Fix
Make the threshold configurable via
GridStackOptions, defaulting to0.5for backward compatibility:Alternative: auto-adjust for float mode
If a new option isn't desirable, the threshold could automatically drop to 0 when
float: true, since overlapping is explicitly allowed in that mode:Current Workaround
We monkey-patch
directionCollideCoverageafterGridStack.init()to return the first non-locked collision immediately:Trade-offs of this workaround:
A first-class configurable threshold would preserve the directional logic while letting users tune the responsiveness.
Environment: GridStack 12.4.2, SvelteKit + Svelte 5,
column: 48, cellHeight: 10, float: true, margin: 2adumesny commentedon Mar 30, 2026
it's not a dead zone, and yes you should cover the (larger) target widget by >50% before moving it out otherwise it wil always push it by 1 row and you could never push it past.
actually now that I write it down it should push and jump past if over 50% of larger object. so always move (if it can) by 50% row coverage.
item not moved (to alt position) when colliding fails with an object