schmelczer-dev/src/framework/helper/get-height.ts
Schmelczer András fd14613db7 Fix some bugs
2020-01-12 20:26:32 +01:00

11 lines
350 B
TypeScript
Executable file

export const getHeight = (e: HTMLElement): number => {
// ignores margin collapse
const computedStyle = window.getComputedStyle(e);
return (
e.clientHeight +
parseInt(computedStyle.marginTop) +
parseInt(computedStyle.marginBottom) +
parseInt(computedStyle.borderTopWidth) +
parseInt(computedStyle.borderBottomWidth)
);
};