@zag-js/rect-utils 1.47.0 → 1.48.0

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.
Files changed (102) hide show
  1. package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/defineProperty.js +11 -0
  2. package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/defineProperty.mjs +11 -0
  3. package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/toPrimitive.js +13 -0
  4. package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/toPrimitive.mjs +13 -0
  5. package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/toPropertyKey.js +8 -0
  6. package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/toPropertyKey.mjs +8 -0
  7. package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/typeof.js +15 -0
  8. package/dist/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/typeof.mjs +10 -0
  9. package/dist/affine-transform.d.mts +36 -39
  10. package/dist/affine-transform.d.ts +36 -39
  11. package/dist/affine-transform.js +189 -187
  12. package/dist/affine-transform.mjs +185 -164
  13. package/dist/align.d.mts +2 -5
  14. package/dist/align.d.ts +2 -5
  15. package/dist/align.js +27 -44
  16. package/dist/align.mjs +23 -21
  17. package/dist/angle.d.mts +2 -5
  18. package/dist/angle.d.ts +2 -5
  19. package/dist/angle.js +8 -32
  20. package/dist/angle.mjs +4 -9
  21. package/dist/clamp.d.mts +8 -11
  22. package/dist/clamp.d.ts +8 -11
  23. package/dist/clamp.js +23 -46
  24. package/dist/clamp.mjs +18 -22
  25. package/dist/closest.d.mts +4 -7
  26. package/dist/closest.d.ts +4 -7
  27. package/dist/closest.js +35 -62
  28. package/dist/closest.mjs +29 -37
  29. package/dist/compass.d.mts +4 -7
  30. package/dist/compass.d.ts +4 -7
  31. package/dist/compass.js +48 -48
  32. package/dist/compass.mjs +43 -24
  33. package/dist/constrain.d.mts +2 -5
  34. package/dist/constrain.d.ts +2 -5
  35. package/dist/constrain.js +12 -37
  36. package/dist/constrain.mjs +8 -14
  37. package/dist/contains.d.mts +4 -7
  38. package/dist/contains.d.ts +4 -7
  39. package/dist/contains.js +11 -36
  40. package/dist/contains.mjs +5 -11
  41. package/dist/distance.d.mts +7 -10
  42. package/dist/distance.d.ts +7 -10
  43. package/dist/distance.js +55 -60
  44. package/dist/distance.mjs +48 -34
  45. package/dist/equality.d.mts +4 -7
  46. package/dist/equality.d.ts +4 -7
  47. package/dist/equality.js +13 -38
  48. package/dist/equality.mjs +7 -13
  49. package/dist/from-element.d.mts +12 -15
  50. package/dist/from-element.d.ts +12 -15
  51. package/dist/from-element.js +39 -58
  52. package/dist/from-element.mjs +35 -35
  53. package/dist/from-points.d.mts +2 -5
  54. package/dist/from-points.d.ts +2 -5
  55. package/dist/from-points.js +18 -36
  56. package/dist/from-points.mjs +14 -13
  57. package/dist/from-range.d.mts +2 -5
  58. package/dist/from-range.d.ts +2 -5
  59. package/dist/from-range.js +25 -46
  60. package/dist/from-range.mjs +19 -21
  61. package/dist/from-rotation.d.mts +4 -7
  62. package/dist/from-rotation.d.ts +4 -7
  63. package/dist/from-rotation.js +31 -56
  64. package/dist/from-rotation.mjs +25 -31
  65. package/dist/from-window.d.mts +13 -16
  66. package/dist/from-window.d.ts +13 -16
  67. package/dist/from-window.js +29 -44
  68. package/dist/from-window.mjs +24 -20
  69. package/dist/index.d.mts +22 -22
  70. package/dist/index.d.ts +22 -22
  71. package/dist/index.js +72 -63
  72. package/dist/index.mjs +21 -22
  73. package/dist/intersection.d.mts +4 -7
  74. package/dist/intersection.d.ts +4 -7
  75. package/dist/intersection.js +34 -45
  76. package/dist/intersection.mjs +28 -20
  77. package/dist/operations.d.mts +6 -9
  78. package/dist/operations.d.ts +6 -9
  79. package/dist/operations.js +38 -57
  80. package/dist/operations.mjs +30 -30
  81. package/dist/polygon.d.mts +6 -9
  82. package/dist/polygon.d.ts +6 -9
  83. package/dist/polygon.js +73 -82
  84. package/dist/polygon.mjs +67 -57
  85. package/dist/rect.d.mts +49 -52
  86. package/dist/rect.d.ts +49 -52
  87. package/dist/rect.js +57 -82
  88. package/dist/rect.mjs +46 -52
  89. package/dist/resize.d.mts +3 -6
  90. package/dist/resize.d.ts +3 -6
  91. package/dist/resize.js +73 -102
  92. package/dist/resize.mjs +68 -78
  93. package/dist/types.d.mts +45 -49
  94. package/dist/types.d.ts +45 -49
  95. package/dist/types.js +4 -18
  96. package/dist/types.mjs +1 -0
  97. package/dist/union.d.mts +2 -5
  98. package/dist/union.d.ts +2 -5
  99. package/dist/union.js +16 -39
  100. package/dist/union.mjs +12 -16
  101. package/package.json +3 -3
  102. package/dist/chunk-QZ7TP4HQ.mjs +0 -7
@@ -1,42 +1,42 @@
1
- import "./chunk-QZ7TP4HQ.mjs";
2
-
3
- // src/from-element.ts
4
1
  import { createRect } from "./rect.mjs";
5
- var styleCache = /* @__PURE__ */ new WeakMap();
2
+ // src/from-element.ts
3
+ const styleCache = /* @__PURE__ */ new WeakMap();
6
4
  function getCacheComputedStyle(el) {
7
- if (!styleCache.has(el)) {
8
- const win = el.ownerDocument.defaultView || window;
9
- styleCache.set(el, win.getComputedStyle(el));
10
- }
11
- return styleCache.get(el);
5
+ if (!styleCache.has(el)) {
6
+ const win = el.ownerDocument.defaultView || window;
7
+ styleCache.set(el, win.getComputedStyle(el));
8
+ }
9
+ return styleCache.get(el);
12
10
  }
13
11
  function getElementRect(el, opts = {}) {
14
- return createRect(getClientRect(el, opts));
12
+ return createRect(getClientRect(el, opts));
15
13
  }
16
14
  function getClientRect(el, opts = {}) {
17
- const { excludeScrollbar = false, excludeBorders = false } = opts;
18
- const { x, y, width, height } = el.getBoundingClientRect();
19
- const r = { x, y, width, height };
20
- const style = getCacheComputedStyle(el);
21
- const { borderLeftWidth, borderTopWidth, borderRightWidth, borderBottomWidth } = style;
22
- const borderXWidth = sum(borderLeftWidth, borderRightWidth);
23
- const borderYWidth = sum(borderTopWidth, borderBottomWidth);
24
- if (excludeBorders) {
25
- r.width -= borderXWidth;
26
- r.height -= borderYWidth;
27
- r.x += px(borderLeftWidth);
28
- r.y += px(borderTopWidth);
29
- }
30
- if (excludeScrollbar) {
31
- const scrollbarWidth = el.offsetWidth - el.clientWidth - borderXWidth;
32
- const scrollbarHeight = el.offsetHeight - el.clientHeight - borderYWidth;
33
- r.width -= scrollbarWidth;
34
- r.height -= scrollbarHeight;
35
- }
36
- return r;
15
+ const { excludeScrollbar = false, excludeBorders = false } = opts;
16
+ const { x, y, width, height } = el.getBoundingClientRect();
17
+ const r = {
18
+ x,
19
+ y,
20
+ width,
21
+ height
22
+ };
23
+ const { borderLeftWidth, borderTopWidth, borderRightWidth, borderBottomWidth } = getCacheComputedStyle(el);
24
+ const borderXWidth = sum(borderLeftWidth, borderRightWidth);
25
+ const borderYWidth = sum(borderTopWidth, borderBottomWidth);
26
+ if (excludeBorders) {
27
+ r.width -= borderXWidth;
28
+ r.height -= borderYWidth;
29
+ r.x += px(borderLeftWidth);
30
+ r.y += px(borderTopWidth);
31
+ }
32
+ if (excludeScrollbar) {
33
+ const scrollbarWidth = el.offsetWidth - el.clientWidth - borderXWidth;
34
+ const scrollbarHeight = el.offsetHeight - el.clientHeight - borderYWidth;
35
+ r.width -= scrollbarWidth;
36
+ r.height -= scrollbarHeight;
37
+ }
38
+ return r;
37
39
  }
38
- var px = (v) => parseFloat(v.replace("px", ""));
39
- var sum = (...vals) => vals.reduce((sum2, v) => sum2 + (v ? px(v) : 0), 0);
40
- export {
41
- getElementRect
42
- };
40
+ const px = (v) => parseFloat(v.replace("px", ""));
41
+ const sum = (...vals) => vals.reduce((sum, v) => sum + (v ? px(v) : 0), 0);
42
+ export { getElementRect };
@@ -1,5 +1,2 @@
1
- import { Point, Rect } from './types.mjs';
2
-
3
- declare function getRectFromPoints(...pts: Point[]): Rect;
4
-
5
- export { getRectFromPoints };
1
+ import { Point, Rect } from "./types.mjs";
2
+ export declare function getRectFromPoints(...pts: Point[]): Rect;
@@ -1,5 +1,2 @@
1
- import { Point, Rect } from './types.js';
2
-
3
- declare function getRectFromPoints(...pts: Point[]): Rect;
4
-
5
- export { getRectFromPoints };
1
+ import { Point, Rect } from "./types.js";
2
+ export declare function getRectFromPoints(...pts: Point[]): Rect;
@@ -1,39 +1,21 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/from-points.ts
21
- var from_points_exports = {};
22
- __export(from_points_exports, {
23
- getRectFromPoints: () => getRectFromPoints
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
24
4
  });
25
- module.exports = __toCommonJS(from_points_exports);
26
- var import_rect = require("./rect.js");
5
+ const require_rect = require("./rect.js");
6
+ // src/from-points.ts
27
7
  function getRectFromPoints(...pts) {
28
- const xs = pts.map((p) => p.x);
29
- const ys = pts.map((p) => p.y);
30
- const x = Math.min(...xs);
31
- const y = Math.min(...ys);
32
- const width = Math.max(...xs) - x;
33
- const height = Math.max(...ys) - y;
34
- return (0, import_rect.createRect)({ x, y, width, height });
8
+ const xs = pts.map((p) => p.x);
9
+ const ys = pts.map((p) => p.y);
10
+ const x = Math.min(...xs);
11
+ const y = Math.min(...ys);
12
+ const width = Math.max(...xs) - x;
13
+ const height = Math.max(...ys) - y;
14
+ return require_rect.createRect({
15
+ x,
16
+ y,
17
+ width,
18
+ height
19
+ });
35
20
  }
36
- // Annotate the CommonJS export names for ESM import in node:
37
- 0 && (module.exports = {
38
- getRectFromPoints
39
- });
21
+ exports.getRectFromPoints = getRectFromPoints;
@@ -1,16 +1,17 @@
1
- import "./chunk-QZ7TP4HQ.mjs";
2
-
3
- // src/from-points.ts
4
1
  import { createRect } from "./rect.mjs";
2
+ // src/from-points.ts
5
3
  function getRectFromPoints(...pts) {
6
- const xs = pts.map((p) => p.x);
7
- const ys = pts.map((p) => p.y);
8
- const x = Math.min(...xs);
9
- const y = Math.min(...ys);
10
- const width = Math.max(...xs) - x;
11
- const height = Math.max(...ys) - y;
12
- return createRect({ x, y, width, height });
4
+ const xs = pts.map((p) => p.x);
5
+ const ys = pts.map((p) => p.y);
6
+ const x = Math.min(...xs);
7
+ const y = Math.min(...ys);
8
+ const width = Math.max(...xs) - x;
9
+ const height = Math.max(...ys) - y;
10
+ return createRect({
11
+ x,
12
+ y,
13
+ width,
14
+ height
15
+ });
13
16
  }
14
- export {
15
- getRectFromPoints
16
- };
17
+ export { getRectFromPoints };
@@ -1,5 +1,2 @@
1
- import { Rect } from './types.mjs';
2
-
3
- declare function fromRange(range: Range): Rect;
4
-
5
- export { fromRange };
1
+ import { Rect } from "./types.mjs";
2
+ export declare function fromRange(range: Range): Rect;
@@ -1,5 +1,2 @@
1
- import { Rect } from './types.js';
2
-
3
- declare function fromRange(range: Range): Rect;
4
-
5
- export { fromRange };
1
+ import { Rect } from "./types.js";
2
+ export declare function fromRange(range: Range): Rect;
@@ -1,49 +1,28 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/from-range.ts
21
- var from_range_exports = {};
22
- __export(from_range_exports, {
23
- fromRange: () => fromRange
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
24
4
  });
25
- module.exports = __toCommonJS(from_range_exports);
26
- var import_rect = require("./rect.js");
27
- var import_from_element = require("./from-element.js");
28
- var import_union = require("./union.js");
5
+ const require_rect = require("./rect.js");
6
+ const require_from_element = require("./from-element.js");
7
+ const require_union = require("./union.js");
8
+ // src/from-range.ts
29
9
  function fromRange(range) {
30
- let rs = [];
31
- const rects = Array.from(range.getClientRects());
32
- if (rects.length) {
33
- rs = rs.concat(rects.map(import_rect.createRect));
34
- return import_union.union.apply(void 0, rs);
35
- }
36
- let start = range.startContainer;
37
- if (start.nodeType === Node.TEXT_NODE) {
38
- start = start.parentNode;
39
- }
40
- if (start instanceof HTMLElement) {
41
- const r = (0, import_from_element.getElementRect)(start);
42
- rs.push({ ...r, x: r.maxX, width: 0 });
43
- }
44
- return import_union.union.apply(void 0, rs);
10
+ let rs = [];
11
+ const rects = Array.from(range.getClientRects());
12
+ if (rects.length) {
13
+ rs = rs.concat(rects.map(require_rect.createRect));
14
+ return require_union.union.apply(void 0, rs);
15
+ }
16
+ let start = range.startContainer;
17
+ if (start.nodeType === Node.TEXT_NODE) start = start.parentNode;
18
+ if (start instanceof HTMLElement) {
19
+ const r = require_from_element.getElementRect(start);
20
+ rs.push({
21
+ ...r,
22
+ x: r.maxX,
23
+ width: 0
24
+ });
25
+ }
26
+ return require_union.union.apply(void 0, rs);
45
27
  }
46
- // Annotate the CommonJS export names for ESM import in node:
47
- 0 && (module.exports = {
48
- fromRange
49
- });
28
+ exports.fromRange = fromRange;
@@ -1,26 +1,24 @@
1
- import "./chunk-QZ7TP4HQ.mjs";
2
-
3
- // src/from-range.ts
4
1
  import { createRect } from "./rect.mjs";
5
2
  import { getElementRect } from "./from-element.mjs";
6
3
  import { union } from "./union.mjs";
4
+ // src/from-range.ts
7
5
  function fromRange(range) {
8
- let rs = [];
9
- const rects = Array.from(range.getClientRects());
10
- if (rects.length) {
11
- rs = rs.concat(rects.map(createRect));
12
- return union.apply(void 0, rs);
13
- }
14
- let start = range.startContainer;
15
- if (start.nodeType === Node.TEXT_NODE) {
16
- start = start.parentNode;
17
- }
18
- if (start instanceof HTMLElement) {
19
- const r = getElementRect(start);
20
- rs.push({ ...r, x: r.maxX, width: 0 });
21
- }
22
- return union.apply(void 0, rs);
6
+ let rs = [];
7
+ const rects = Array.from(range.getClientRects());
8
+ if (rects.length) {
9
+ rs = rs.concat(rects.map(createRect));
10
+ return union.apply(void 0, rs);
11
+ }
12
+ let start = range.startContainer;
13
+ if (start.nodeType === Node.TEXT_NODE) start = start.parentNode;
14
+ if (start instanceof HTMLElement) {
15
+ const r = getElementRect(start);
16
+ rs.push({
17
+ ...r,
18
+ x: r.maxX,
19
+ width: 0
20
+ });
21
+ }
22
+ return union.apply(void 0, rs);
23
23
  }
24
- export {
25
- fromRange
26
- };
24
+ export { fromRange };
@@ -1,7 +1,4 @@
1
- import { Rect, Point } from './types.mjs';
2
-
3
- declare function toRad(d: number): number;
4
- declare function rotate(a: Point, d: number, c: Point): Point;
5
- declare function getRotationRect(r: Rect, deg: number): Rect;
6
-
7
- export { getRotationRect, rotate, toRad };
1
+ import { Point, Rect } from "./types.mjs";
2
+ export declare function toRad(d: number): number;
3
+ export declare function rotate(a: Point, d: number, c: Point): Point;
4
+ export declare function getRotationRect(r: Rect, deg: number): Rect;
@@ -1,7 +1,4 @@
1
- import { Rect, Point } from './types.js';
2
-
3
- declare function toRad(d: number): number;
4
- declare function rotate(a: Point, d: number, c: Point): Point;
5
- declare function getRotationRect(r: Rect, deg: number): Rect;
6
-
7
- export { getRotationRect, rotate, toRad };
1
+ import { Point, Rect } from "./types.js";
2
+ export declare function toRad(d: number): number;
3
+ export declare function rotate(a: Point, d: number, c: Point): Point;
4
+ export declare function getRotationRect(r: Rect, deg: number): Rect;
@@ -1,63 +1,38 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/from-rotation.ts
21
- var from_rotation_exports = {};
22
- __export(from_rotation_exports, {
23
- getRotationRect: () => getRotationRect,
24
- rotate: () => rotate,
25
- toRad: () => toRad
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
26
4
  });
27
- module.exports = __toCommonJS(from_rotation_exports);
28
- var import_rect = require("./rect.js");
5
+ const require_rect = require("./rect.js");
6
+ // src/from-rotation.ts
29
7
  function toRad(d) {
30
- return d % 360 * Math.PI / 180;
8
+ return d % 360 * Math.PI / 180;
31
9
  }
32
10
  function rotate(a, d, c) {
33
- const r = toRad(d);
34
- const sin = Math.sin(r);
35
- const cos = Math.cos(r);
36
- const x = a.x - c.x;
37
- const y = a.y - c.y;
38
- return {
39
- x: c.x + x * cos - y * sin,
40
- y: c.y + x * sin + y * cos
41
- };
11
+ const r = toRad(d);
12
+ const sin = Math.sin(r);
13
+ const cos = Math.cos(r);
14
+ const x = a.x - c.x;
15
+ const y = a.y - c.y;
16
+ return {
17
+ x: c.x + x * cos - y * sin,
18
+ y: c.y + x * sin + y * cos
19
+ };
42
20
  }
43
21
  function getRotationRect(r, deg) {
44
- const rr = Object.values((0, import_rect.getRectCorners)(r)).map((p) => rotate(p, deg, r.center));
45
- const xs = rr.map((p) => p.x);
46
- const ys = rr.map((p) => p.y);
47
- const minX = Math.min(...xs);
48
- const minY = Math.min(...ys);
49
- const maxX = Math.max(...xs);
50
- const maxY = Math.max(...ys);
51
- return (0, import_rect.createRect)({
52
- x: minX,
53
- y: minY,
54
- width: maxX - minX,
55
- height: maxY - minY
56
- });
22
+ const rr = Object.values(require_rect.getRectCorners(r)).map((p) => rotate(p, deg, r.center));
23
+ const xs = rr.map((p) => p.x);
24
+ const ys = rr.map((p) => p.y);
25
+ const minX = Math.min(...xs);
26
+ const minY = Math.min(...ys);
27
+ const maxX = Math.max(...xs);
28
+ const maxY = Math.max(...ys);
29
+ return require_rect.createRect({
30
+ x: minX,
31
+ y: minY,
32
+ width: maxX - minX,
33
+ height: maxY - minY
34
+ });
57
35
  }
58
- // Annotate the CommonJS export names for ESM import in node:
59
- 0 && (module.exports = {
60
- getRotationRect,
61
- rotate,
62
- toRad
63
- });
36
+ exports.getRotationRect = getRotationRect;
37
+ exports.rotate = rotate;
38
+ exports.toRad = toRad;
@@ -1,38 +1,32 @@
1
- import "./chunk-QZ7TP4HQ.mjs";
2
-
3
- // src/from-rotation.ts
4
1
  import { createRect, getRectCorners } from "./rect.mjs";
2
+ // src/from-rotation.ts
5
3
  function toRad(d) {
6
- return d % 360 * Math.PI / 180;
4
+ return d % 360 * Math.PI / 180;
7
5
  }
8
6
  function rotate(a, d, c) {
9
- const r = toRad(d);
10
- const sin = Math.sin(r);
11
- const cos = Math.cos(r);
12
- const x = a.x - c.x;
13
- const y = a.y - c.y;
14
- return {
15
- x: c.x + x * cos - y * sin,
16
- y: c.y + x * sin + y * cos
17
- };
7
+ const r = toRad(d);
8
+ const sin = Math.sin(r);
9
+ const cos = Math.cos(r);
10
+ const x = a.x - c.x;
11
+ const y = a.y - c.y;
12
+ return {
13
+ x: c.x + x * cos - y * sin,
14
+ y: c.y + x * sin + y * cos
15
+ };
18
16
  }
19
17
  function getRotationRect(r, deg) {
20
- const rr = Object.values(getRectCorners(r)).map((p) => rotate(p, deg, r.center));
21
- const xs = rr.map((p) => p.x);
22
- const ys = rr.map((p) => p.y);
23
- const minX = Math.min(...xs);
24
- const minY = Math.min(...ys);
25
- const maxX = Math.max(...xs);
26
- const maxY = Math.max(...ys);
27
- return createRect({
28
- x: minX,
29
- y: minY,
30
- width: maxX - minX,
31
- height: maxY - minY
32
- });
18
+ const rr = Object.values(getRectCorners(r)).map((p) => rotate(p, deg, r.center));
19
+ const xs = rr.map((p) => p.x);
20
+ const ys = rr.map((p) => p.y);
21
+ const minX = Math.min(...xs);
22
+ const minY = Math.min(...ys);
23
+ const maxX = Math.max(...xs);
24
+ const maxY = Math.max(...ys);
25
+ return createRect({
26
+ x: minX,
27
+ y: minY,
28
+ width: maxX - minX,
29
+ height: maxY - minY
30
+ });
33
31
  }
34
- export {
35
- getRotationRect,
36
- rotate,
37
- toRad
38
- };
32
+ export { getRotationRect, rotate, toRad };
@@ -1,23 +1,20 @@
1
- import { Rect } from './types.mjs';
2
-
3
- type WindowRectOptions = {
4
- /**
5
- * Whether to exclude the element's scrollbar size from the calculation.
6
- */
7
- excludeScrollbar?: boolean | undefined;
1
+ import { Rect } from "./types.mjs";
2
+ export type WindowRectOptions = {
3
+ /**
4
+ * Whether to exclude the element's scrollbar size from the calculation.
5
+ */
6
+ excludeScrollbar?: boolean | undefined;
8
7
  };
9
8
  /**
10
9
  * Creates a rectangle from window object
11
10
  */
12
- declare function getWindowRect(win: Window, opts?: WindowRectOptions): Rect;
11
+ export declare function getWindowRect(win: Window, opts?: WindowRectOptions): Rect;
13
12
  /**
14
13
  * Get the rect of the window with the option to exclude the scrollbar
15
14
  */
16
- declare function getViewportRect(win: Window, opts: WindowRectOptions): {
17
- x: number;
18
- y: number;
19
- width: number;
20
- height: number;
21
- };
22
-
23
- export { type WindowRectOptions, getViewportRect, getWindowRect };
15
+ export declare function getViewportRect(win: Window, opts: WindowRectOptions): {
16
+ x: number;
17
+ y: number;
18
+ width: number;
19
+ height: number;
20
+ };
@@ -1,23 +1,20 @@
1
- import { Rect } from './types.js';
2
-
3
- type WindowRectOptions = {
4
- /**
5
- * Whether to exclude the element's scrollbar size from the calculation.
6
- */
7
- excludeScrollbar?: boolean | undefined;
1
+ import { Rect } from "./types.js";
2
+ export type WindowRectOptions = {
3
+ /**
4
+ * Whether to exclude the element's scrollbar size from the calculation.
5
+ */
6
+ excludeScrollbar?: boolean | undefined;
8
7
  };
9
8
  /**
10
9
  * Creates a rectangle from window object
11
10
  */
12
- declare function getWindowRect(win: Window, opts?: WindowRectOptions): Rect;
11
+ export declare function getWindowRect(win: Window, opts?: WindowRectOptions): Rect;
13
12
  /**
14
13
  * Get the rect of the window with the option to exclude the scrollbar
15
14
  */
16
- declare function getViewportRect(win: Window, opts: WindowRectOptions): {
17
- x: number;
18
- y: number;
19
- width: number;
20
- height: number;
21
- };
22
-
23
- export { type WindowRectOptions, getViewportRect, getWindowRect };
15
+ export declare function getViewportRect(win: Window, opts: WindowRectOptions): {
16
+ x: number;
17
+ y: number;
18
+ width: number;
19
+ height: number;
20
+ };