@zag-js/rect-utils
Advanced tools
Comparing version 0.56.0 to 0.56.1
@@ -20,6 +20,3 @@ "use strict"; | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
var __publicField = (obj, key, value) => { | ||
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); | ||
return value; | ||
}; | ||
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); | ||
@@ -205,4 +202,3 @@ // src/index.ts | ||
static multiply(...[first, ...rest]) { | ||
if (!first) | ||
return _AffineTransform.identity; | ||
if (!first) return _AffineTransform.identity; | ||
return rest.reduce((result, item) => result.prepend(item), first); | ||
@@ -245,12 +241,7 @@ } | ||
let x = ref.minX; | ||
if (h === "left-inside") | ||
x = ref.minX; | ||
if (h === "left-outside") | ||
x = ref.minX - ref.width; | ||
if (h === "right-inside") | ||
x = ref.maxX - ref.width; | ||
if (h === "right-outside") | ||
x = ref.maxX; | ||
if (h === "center") | ||
x = ref.midX - ref.width / 2; | ||
if (h === "left-inside") x = ref.minX; | ||
if (h === "left-outside") x = ref.minX - ref.width; | ||
if (h === "right-inside") x = ref.maxX - ref.width; | ||
if (h === "right-outside") x = ref.maxX; | ||
if (h === "center") x = ref.midX - ref.width / 2; | ||
return { ...a, x }; | ||
@@ -260,12 +251,7 @@ } | ||
let y = ref.minY; | ||
if (v === "top-inside") | ||
y = ref.minY; | ||
if (v === "top-outside") | ||
y = ref.minY - a.height; | ||
if (v === "bottom-inside") | ||
y = ref.maxY - a.height; | ||
if (v === "bottom-outside") | ||
y = ref.maxY; | ||
if (v === "center") | ||
y = ref.midY - a.height / 2; | ||
if (v === "top-inside") y = ref.minY; | ||
if (v === "top-outside") y = ref.minY - a.height; | ||
if (v === "bottom-inside") y = ref.maxY - a.height; | ||
if (v === "bottom-outside") y = ref.maxY; | ||
if (v === "center") y = ref.midY - a.height / 2; | ||
return { ...a, y }; | ||
@@ -378,15 +364,10 @@ } | ||
let y = 0; | ||
if (p.x < r.x) | ||
x = r.x - p.x; | ||
else if (p.x > r.maxX) | ||
x = p.x - r.maxX; | ||
if (p.y < r.y) | ||
y = r.y - p.y; | ||
else if (p.y > r.maxY) | ||
y = p.y - r.maxY; | ||
if (p.x < r.x) x = r.x - p.x; | ||
else if (p.x > r.maxX) x = p.x - r.maxX; | ||
if (p.y < r.y) y = r.y - p.y; | ||
else if (p.y > r.maxY) y = p.y - r.maxY; | ||
return { x, y, value: distance({ x, y }) }; | ||
} | ||
function distanceFromRect(a, b) { | ||
if (intersects(a, b)) | ||
return { x: 0, y: 0, value: 0 }; | ||
if (intersects(a, b)) return { x: 0, y: 0, value: 0 }; | ||
const left = a.x < b.x ? a : b; | ||
@@ -420,10 +401,6 @@ const right = b.x < a.x ? a : b; | ||
function closestSideToRect(ref, r) { | ||
if (r.maxX <= ref.minX) | ||
return "left"; | ||
if (r.minX >= ref.maxX) | ||
return "right"; | ||
if (r.maxY <= ref.minY) | ||
return "top"; | ||
if (r.minY >= ref.maxY) | ||
return "bottom"; | ||
if (r.maxX <= ref.minX) return "left"; | ||
if (r.minX >= ref.maxX) return "right"; | ||
if (r.maxY <= ref.minY) return "top"; | ||
if (r.minY >= ref.maxY) return "bottom"; | ||
return "left"; | ||
@@ -430,0 +407,0 @@ } |
{ | ||
"name": "@zag-js/rect-utils", | ||
"version": "0.56.0", | ||
"version": "0.56.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
182889
2609