@maas/vue-equipment 1.0.0-beta.71 → 1.0.0-beta.72

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@maas/vue-equipment/nuxt",
3
3
  "configKey": "vueEquipment",
4
- "version": "1.0.0-beta.70",
4
+ "version": "1.0.0-beta.71",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "unknown"
@@ -136,14 +136,9 @@ export function useTrayMagnetism(args) {
136
136
  );
137
137
  return match ? match.direction : null;
138
138
  }
139
- function handleHalfThickness(side) {
139
+ function handleRect(side) {
140
140
  const handle = unrefElement(handleRefs[side].value?.[0]);
141
- if (!handle) {
142
- return 0;
143
- }
144
- const rect = handle.getBoundingClientRect();
145
- const size = side === "top" || side === "bottom" ? rect.height : rect.width;
146
- return size / 2;
141
+ return handle ? handle.getBoundingClientRect() : null;
147
142
  }
148
143
  function cancelSettle(side) {
149
144
  if (settleId[side] !== void 0) {
@@ -222,7 +217,9 @@ export function useTrayMagnetism(args) {
222
217
  }
223
218
  const allowInner = direction === "inner" || direction === "both";
224
219
  const allowOuter = direction === "outer" || direction === "both";
225
- const anchorHalf = handleHalfThickness(side);
220
+ const hRect = handleRect(side);
221
+ const thickness = hRect ? side === "top" || side === "bottom" ? hRect.height : hRect.width : 0;
222
+ const anchorHalf = thickness / 2;
226
223
  const radius = configuredRadius > 0 ? configuredRadius : anchorHalf / 2;
227
224
  const pull = configuredPull > 0 ? configuredPull : anchorHalf / 2;
228
225
  pullPx[side] = pull;
@@ -234,30 +231,53 @@ export function useTrayMagnetism(args) {
234
231
  }
235
232
  let perp = 0;
236
233
  let overflow = 0;
234
+ let center = 0;
237
235
  switch (side) {
238
- case "top":
239
- perp = y - (rect.top + state.snapped.top);
236
+ case "top": {
237
+ const edge = rect.top + state.snapped.top;
238
+ perp = y - edge;
240
239
  overflow = axisOverflow(x, rect.left, rect.right);
240
+ if (hRect) {
241
+ center = hRect.top + hRect.height / 2 - edge - state.magnetic.top;
242
+ }
241
243
  break;
242
- case "bottom":
243
- perp = rect.bottom - state.snapped.bottom - y;
244
+ }
245
+ case "bottom": {
246
+ const edge = rect.bottom - state.snapped.bottom;
247
+ perp = edge - y;
244
248
  overflow = axisOverflow(x, rect.left, rect.right);
249
+ if (hRect) {
250
+ center = edge - (hRect.top + hRect.height / 2) - state.magnetic.bottom;
251
+ }
245
252
  break;
246
- case "left":
247
- perp = x - (rect.left + state.snapped.left);
253
+ }
254
+ case "left": {
255
+ const edge = rect.left + state.snapped.left;
256
+ perp = x - edge;
248
257
  overflow = axisOverflow(y, rect.top, rect.bottom);
258
+ if (hRect) {
259
+ center = hRect.left + hRect.width / 2 - edge - state.magnetic.left;
260
+ }
249
261
  break;
250
- case "right":
251
- perp = rect.right - state.snapped.right - x;
262
+ }
263
+ case "right": {
264
+ const edge = rect.right - state.snapped.right;
265
+ perp = edge - x;
252
266
  overflow = axisOverflow(y, rect.top, rect.bottom);
267
+ if (hRect) {
268
+ center = edge - (hRect.left + hRect.width / 2) - state.magnetic.right;
269
+ }
253
270
  break;
271
+ }
254
272
  }
273
+ const innerEdge = center + anchorHalf;
274
+ const outerEdge = center - anchorHalf;
255
275
  if (overflow === 0) {
256
276
  switch (true) {
257
- case (allowInner && perp >= anchorHalf):
277
+ case (allowInner && perp >= innerEdge):
258
278
  armedDir[side] = "inner";
259
279
  break;
260
- case (allowOuter && perp <= -anchorHalf):
280
+ case (allowOuter && perp <= outerEdge):
261
281
  armedDir[side] = "outer";
262
282
  break;
263
283
  }
@@ -271,11 +291,11 @@ export function useTrayMagnetism(args) {
271
291
  let sign = 0;
272
292
  switch (dir) {
273
293
  case "inner":
274
- t = clampValue((anchorHalf - perp) / radius, 0, 1);
294
+ t = clampValue((innerEdge - perp) / radius, 0, 1);
275
295
  sign = 1;
276
296
  break;
277
297
  case "outer":
278
- t = clampValue((anchorHalf + perp) / radius, 0, 1);
298
+ t = clampValue((perp - outerEdge) / radius, 0, 1);
279
299
  sign = -1;
280
300
  break;
281
301
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@maas/vue-equipment",
3
3
  "description": "Our Frontend Toolkit, Free and Open Source",
4
- "version": "1.0.0-beta.71",
4
+ "version": "1.0.0-beta.72",
5
5
  "contributors": [
6
6
  {
7
7
  "name": "Robin Scholz",