@dnd-kit/collision 0.2.3 → 0.2.4-beta-20260207150257
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +10 -3
- package/dist/index.js +10 -3
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -166,11 +166,18 @@ var directionBiased = ({
|
|
|
166
166
|
if (direction === null) {
|
|
167
167
|
return defaultCollisionDetection({ dragOperation, droppable });
|
|
168
168
|
}
|
|
169
|
-
const { center
|
|
170
|
-
|
|
169
|
+
const { center } = shape.current;
|
|
170
|
+
const rect = droppable.shape.boundingRectangle;
|
|
171
|
+
const isBelow = rect.bottom >= center.y;
|
|
172
|
+
const isAbove = rect.top <= center.y;
|
|
173
|
+
const isLeft = rect.left <= center.x;
|
|
174
|
+
const isRight = rect.right >= center.x;
|
|
175
|
+
if (direction === "down" && isBelow || direction === "up" && isAbove || direction === "left" && isLeft || direction === "right" && isRight) {
|
|
176
|
+
const distance = import_geometry5.Point.distance(droppable.shape.center, center);
|
|
177
|
+
const value = distance === 0 ? 1 : 1 / distance;
|
|
171
178
|
return {
|
|
172
179
|
id: droppable.id,
|
|
173
|
-
value
|
|
180
|
+
value,
|
|
174
181
|
type: import_abstract5.CollisionType.Collision,
|
|
175
182
|
priority: import_abstract5.CollisionPriority.Normal
|
|
176
183
|
};
|
package/dist/index.js
CHANGED
|
@@ -134,11 +134,18 @@ var directionBiased = ({
|
|
|
134
134
|
if (direction === null) {
|
|
135
135
|
return defaultCollisionDetection({ dragOperation, droppable });
|
|
136
136
|
}
|
|
137
|
-
const { center
|
|
138
|
-
|
|
137
|
+
const { center } = shape.current;
|
|
138
|
+
const rect = droppable.shape.boundingRectangle;
|
|
139
|
+
const isBelow = rect.bottom >= center.y;
|
|
140
|
+
const isAbove = rect.top <= center.y;
|
|
141
|
+
const isLeft = rect.left <= center.x;
|
|
142
|
+
const isRight = rect.right >= center.x;
|
|
143
|
+
if (direction === "down" && isBelow || direction === "up" && isAbove || direction === "left" && isLeft || direction === "right" && isRight) {
|
|
144
|
+
const distance = Point5.distance(droppable.shape.center, center);
|
|
145
|
+
const value = distance === 0 ? 1 : 1 / distance;
|
|
139
146
|
return {
|
|
140
147
|
id: droppable.id,
|
|
141
|
-
value
|
|
148
|
+
value,
|
|
142
149
|
type: CollisionType5.Collision,
|
|
143
150
|
priority: CollisionPriority5.Normal
|
|
144
151
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dnd-kit/collision",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.4-beta-20260207150257",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@dnd-kit/abstract": "
|
|
28
|
-
"@dnd-kit/geometry": "
|
|
27
|
+
"@dnd-kit/abstract": "0.2.4-beta-20260207150257",
|
|
28
|
+
"@dnd-kit/geometry": "0.2.4-beta-20260207150257",
|
|
29
29
|
"tslib": "^2.6.2"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|