fix dimensions api

This commit is contained in:
Rene
2020-08-30 23:41:30 +02:00
parent 9292a64391
commit 7e419b0d8c
2 changed files with 3 additions and 4 deletions
@@ -1,6 +1,5 @@
import { WH } from 'support/dom';
const zeroDomRect = new DOMRect();
const zeroObj: WH = {
w: 0,
h: 0,
@@ -27,4 +26,4 @@ export const clientSize = (elm: HTMLElement | null): WH =>
}
: zeroObj;
export const getBoundingClientRect = (elm: HTMLElement | null): DOMRect => (elm ? elm.getBoundingClientRect() : zeroDomRect);
export const getBoundingClientRect = (elm: HTMLElement): DOMRect => elm.getBoundingClientRect();
@@ -1,4 +1,4 @@
import { XY } from 'support/dom';
import { XY, getBoundingClientRect } from 'support/dom';
const zeroObj: XY = {
x: 0,
@@ -6,7 +6,7 @@ const zeroObj: XY = {
};
export const offset = (elm: HTMLElement | null): XY => {
const rect = elm ? elm.getBoundingClientRect() : 0;
const rect = elm ? getBoundingClientRect(elm) : 0;
return rect
? {
x: rect.left + window.pageYOffset,