@cn-ui/core
Version:
The @cn-ui/core is a collection of UI components and utilities for building modern web applications with SolidJS.
23 lines (21 loc) • 793 B
text/typescript
const getPadding = (el: HTMLElement) => {
const style = window.getComputedStyle(el, null);
const paddingLeft = Number.parseInt(style.paddingLeft, 10) || 0;
const paddingRight = Number.parseInt(style.paddingRight, 10) || 0;
const paddingTop = Number.parseInt(style.paddingTop, 10) || 0;
const paddingBottom = Number.parseInt(style.paddingBottom, 10) || 0;
return {
left: paddingLeft,
right: paddingRight,
top: paddingTop,
bottom: paddingBottom,
};
};
export const checkEllipsis = (box: HTMLElement, content: HTMLElement) => {
const { left, right } = getPadding(box);
const horizontalPadding = left + right;
if (box.clientWidth <= content.offsetWidth + horizontalPadding) {
return true;
}
return false;
};