mirror of
https://github.com/tenrok/OverlayScrollbars.git
synced 2026-05-20 05:39:39 +03:00
fix dimensions api
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user