Files
NapCatQQ/.pnpm-store/v3/files/27/0890f49bf96036cc9f8c21a7b01e2a90c024013327c0e600002778fec779d1a09a410ea82b549d6a230f4fa6a7c16e4d2ba92444f03b541424a59ebb1d9799
T
TanTan e311ca3275
Build NapCat Artifacts / Type Check & Test (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

26 lines
694 B
Plaintext

"use client";
// src/dimensions.ts
var getCSSStyleVal = (str, parentNum) => {
if (!str)
return 0;
const strVal = str.includes("px") ? +str.split("px")[0] : str.includes("%") ? +str.split("%")[0] * parentNum * 0.01 : str;
return Number.isNaN(+strVal) ? 0 : +strVal;
};
var getRealShape = (el) => {
const defaultShape = { width: 0, height: 0 };
if (!el || typeof window === "undefined")
return defaultShape;
const rect = el.getBoundingClientRect();
const { width, height } = window.getComputedStyle(el);
return {
width: getCSSStyleVal(`${width}`, rect.width),
height: getCSSStyleVal(`${height}`, rect.height)
};
};
export {
getCSSStyleVal,
getRealShape
};