@floegence/floe-webapp-core 0.52.11 → 0.52.12

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.
@@ -36,4 +36,4 @@ export declare function resolveSurfaceFloatingPanelInset(value: unknown): number
36
36
  export declare function resolveSurfaceFloatingPanelSnapThreshold(value: unknown): number;
37
37
  export declare function resolveSurfaceFloatingPanelBounds(geometry: SurfaceFloatingPanelGeometry, inset?: number): SurfaceFloatingPanelBounds;
38
38
  export declare function resolveSurfaceFloatingPanelPosition(bounds: SurfaceFloatingPanelBounds, placement: SurfaceFloatingPanelPosition): SurfaceFloatingPanelPosition;
39
- export declare function resolveSurfaceFloatingPanelSnap(position: SurfaceFloatingPanelPosition, bounds: SurfaceFloatingPanelBounds, threshold?: number): SurfaceFloatingPanelSnap | null;
39
+ export declare function resolveSurfaceFloatingPanelSnap(position: SurfaceFloatingPanelPosition, bounds: SurfaceFloatingPanelBounds, threshold?: number, direction?: SurfaceFloatingPanelPosition): SurfaceFloatingPanelSnap | null;
@@ -1,78 +1,78 @@
1
1
  const u = 8;
2
- function h(t, n) {
3
- const e = Number(t);
4
- return Number.isFinite(e) && e >= 0 ? e : n;
2
+ function m(t, n) {
3
+ const a = Number(t);
4
+ return Number.isFinite(a) && a >= 0 ? a : n;
5
5
  }
6
- function M(t, n = {}) {
7
- const e = Math.max(0, t.width), o = Math.max(0, t.height), i = Math.min(h(n.left, 0), e), a = Math.min(h(n.top, 0), o), c = Math.min(h(n.right, 0), Math.max(0, e - i)), r = Math.min(h(n.bottom, 0), Math.max(0, o - a));
6
+ function F(t, n = {}) {
7
+ const a = Math.max(0, t.width), e = Math.max(0, t.height), o = Math.min(m(n.left, 0), a), x = Math.min(m(n.top, 0), e), c = Math.min(m(n.right, 0), Math.max(0, a - o)), i = Math.min(m(n.bottom, 0), Math.max(0, e - x));
8
8
  return {
9
9
  ...t,
10
- left: t.left + i,
11
- top: t.top + a,
12
- width: Math.max(0, e - i - c),
13
- height: Math.max(0, o - a - r)
10
+ left: t.left + o,
11
+ top: t.top + x,
12
+ width: Math.max(0, a - o - c),
13
+ height: Math.max(0, e - x - i)
14
14
  };
15
15
  }
16
- function s(t) {
17
- return h(t, 8);
18
- }
19
16
  function f(t) {
17
+ return m(t, 8);
18
+ }
19
+ function M(t) {
20
20
  const n = Number(t);
21
21
  return Number.isFinite(n) && n >= 0 ? n : 1 / 0;
22
22
  }
23
- function l(t, n, e, o) {
24
- const i = Math.max(0, Number.isFinite(n) ? n : 0), a = Math.max(0, Number.isFinite(e) ? e : 0), c = Math.min(o, i / 2), r = t + c, m = Math.max(r, t + i - a - c);
25
- return { min: r, max: m, room: Math.max(0, m - r) };
23
+ function l(t, n, a, e) {
24
+ const o = Math.max(0, Number.isFinite(n) ? n : 0), x = Math.max(0, Number.isFinite(a) ? a : 0), c = Math.min(e, o / 2), i = t + c, h = Math.max(i, t + o - x - c);
25
+ return { min: i, max: h, room: Math.max(0, h - i) };
26
26
  }
27
- function F(t, n = 8) {
28
- const e = s(n);
27
+ function N(t, n = 8) {
28
+ const a = f(n);
29
29
  return {
30
- x: l(t.left, t.width, t.panelWidth, e),
31
- y: l(t.top, t.height, t.panelHeight, e)
30
+ x: l(t.left, t.width, t.panelWidth, a),
31
+ y: l(t.top, t.height, t.panelHeight, a)
32
32
  };
33
33
  }
34
- function N(t, n) {
34
+ function y(t, n) {
35
35
  return {
36
36
  x: t.x.min + n.x * t.x.room,
37
37
  y: t.y.min + n.y * t.y.room
38
38
  };
39
39
  }
40
- function x(t, n) {
40
+ function r(t, n) {
41
41
  return Math.max(n.min, Math.min(n.max, t));
42
42
  }
43
- function S(t, n, e = 1 / 0) {
44
- const o = f(e), i = [
43
+ function S(t, n, a = 1 / 0, e = { x: 0, y: 0 }) {
44
+ const o = M(a), x = [
45
45
  {
46
46
  edge: "left",
47
47
  distance: Math.max(0, t.x - n.x.min),
48
- position: { x: n.x.min, y: x(t.y, n.y) }
48
+ position: { x: n.x.min, y: r(t.y, n.y) }
49
49
  },
50
50
  {
51
51
  edge: "right",
52
52
  distance: Math.max(0, n.x.max - t.x),
53
- position: { x: n.x.max, y: x(t.y, n.y) }
53
+ position: { x: n.x.max, y: r(t.y, n.y) }
54
54
  },
55
55
  {
56
56
  edge: "top",
57
57
  distance: Math.max(0, t.y - n.y.min),
58
- position: { x: x(t.x, n.x), y: n.y.min }
58
+ position: { x: r(t.x, n.x), y: n.y.min }
59
59
  },
60
60
  {
61
61
  edge: "bottom",
62
62
  distance: Math.max(0, n.y.max - t.y),
63
- position: { x: x(t.x, n.x), y: n.y.max }
63
+ position: { x: r(t.x, n.x), y: n.y.max }
64
64
  }
65
- ];
66
- i.sort((c, r) => c.distance - r.distance);
67
- const a = i[0];
68
- return !a || a.distance > o ? null : { edge: a.edge, position: a.position };
65
+ ], c = { left: -e.x, right: e.x, top: -e.y, bottom: e.y };
66
+ x.sort((h, s) => Math.abs(h.distance - s.distance) < 0.01 ? c[s.edge] - c[h.edge] : h.distance - s.distance);
67
+ const i = x[0];
68
+ return !i || i.distance > o ? null : { edge: i.edge, position: i.position };
69
69
  }
70
70
  export {
71
71
  u as DEFAULT_SURFACE_FLOATING_PANEL_INSET,
72
- M as insetSurfaceFloatingPanelGeometry,
73
- F as resolveSurfaceFloatingPanelBounds,
74
- s as resolveSurfaceFloatingPanelInset,
75
- N as resolveSurfaceFloatingPanelPosition,
72
+ F as insetSurfaceFloatingPanelGeometry,
73
+ N as resolveSurfaceFloatingPanelBounds,
74
+ f as resolveSurfaceFloatingPanelInset,
75
+ y as resolveSurfaceFloatingPanelPosition,
76
76
  S as resolveSurfaceFloatingPanelSnap,
77
- f as resolveSurfaceFloatingPanelSnapThreshold
77
+ M as resolveSurfaceFloatingPanelSnapThreshold
78
78
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floegence/floe-webapp-core",
3
- "version": "0.52.11",
3
+ "version": "0.52.12",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",