@zag-js/element-rect
Advanced tools
Comparing version 0.0.0-dev-20230706120929 to 0.0.0-dev-20230710092359
@@ -8,3 +8,3 @@ type Rect = { | ||
type TrackScope = "size" | "position" | "rect"; | ||
export type ElementRectOptions = { | ||
type ElementRectOptions = { | ||
onChange: (rect: Rect) => void; | ||
@@ -14,3 +14,4 @@ scope?: TrackScope; | ||
}; | ||
export declare function trackElementRect(el: HTMLElement, options: ElementRectOptions): () => void; | ||
export {}; | ||
declare function trackElementRect(el: HTMLElement, options: ElementRectOptions): () => void; | ||
export { ElementRectOptions, trackElementRect }; |
@@ -1,8 +0,29 @@ | ||
'use strict'; | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return to; | ||
}; | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
let rafId; | ||
const observedElements = /* @__PURE__ */ new Map(); | ||
const getRectFn = (el) => el.getBoundingClientRect(); | ||
// src/index.ts | ||
var src_exports = {}; | ||
__export(src_exports, { | ||
trackElementRect: () => trackElementRect | ||
}); | ||
module.exports = __toCommonJS(src_exports); | ||
var rafId; | ||
var observedElements = /* @__PURE__ */ new Map(); | ||
var getRectFn = (el) => el.getBoundingClientRect(); | ||
function trackElementRect(el, options) { | ||
@@ -58,5 +79,5 @@ const { scope = "rect", getRect = getRectFn, onChange } = options; | ||
} | ||
const isEqualSize = (a, b) => a.width === b.width && a.height === b.height; | ||
const isEqualPosition = (a, b) => a.top === b.top && a.left === b.left; | ||
const isEqualRect = (a, b) => isEqualSize(a, b) && isEqualPosition(a, b); | ||
var isEqualSize = (a, b) => a.width === b.width && a.height === b.height; | ||
var isEqualPosition = (a, b) => a.top === b.top && a.left === b.left; | ||
var isEqualRect = (a, b) => isEqualSize(a, b) && isEqualPosition(a, b); | ||
function getEqualityFn(scope) { | ||
@@ -69,3 +90,6 @@ if (scope === "size") | ||
} | ||
exports.trackElementRect = trackElementRect; | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
trackElementRect | ||
}); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@zag-js/element-rect", | ||
"version": "0.0.0-dev-20230706120929", | ||
"version": "0.0.0-dev-20230710092359", | ||
"description": "observe element's rect over time", | ||
@@ -41,3 +41,3 @@ "keywords": [ | ||
"scripts": { | ||
"build": "vite build -c ../../../vite.config.ts", | ||
"build": "tsup", | ||
"lint": "eslint src --ext .ts,.tsx", | ||
@@ -44,0 +44,0 @@ "typecheck": "tsc --noEmit" |
Sorry, the diff of this file is not supported yet
19077
10
249