mirror of
https://github.com/tenrok/OverlayScrollbars.git
synced 2026-06-16 14:00:37 +03:00
fix dimensions api
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
import { WH } from 'support/dom';
|
import { WH } from 'support/dom';
|
||||||
|
|
||||||
const zeroDomRect = new DOMRect();
|
|
||||||
const zeroObj: WH = {
|
const zeroObj: WH = {
|
||||||
w: 0,
|
w: 0,
|
||||||
h: 0,
|
h: 0,
|
||||||
@@ -27,4 +26,4 @@ export const clientSize = (elm: HTMLElement | null): WH =>
|
|||||||
}
|
}
|
||||||
: zeroObj;
|
: 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 = {
|
const zeroObj: XY = {
|
||||||
x: 0,
|
x: 0,
|
||||||
@@ -6,7 +6,7 @@ const zeroObj: XY = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const offset = (elm: HTMLElement | null): XY => {
|
export const offset = (elm: HTMLElement | null): XY => {
|
||||||
const rect = elm ? elm.getBoundingClientRect() : 0;
|
const rect = elm ? getBoundingClientRect(elm) : 0;
|
||||||
return rect
|
return rect
|
||||||
? {
|
? {
|
||||||
x: rect.left + window.pageYOffset,
|
x: rect.left + window.pageYOffset,
|
||||||
|
|||||||
Reference in New Issue
Block a user