@vkontakte/vkjs
Advanced tools
Comparing version 0.11.0 to 0.11.1
export function getOffsetRect(elem) { | ||
if (typeof window === 'undefined') { | ||
var isElement = elem instanceof HTMLElement; | ||
if (typeof window === 'undefined' || !isElement) { | ||
return { | ||
@@ -11,3 +13,4 @@ top: 0, | ||
var box = elem.getBoundingClientRect(); | ||
var el = elem; | ||
var box = el.getBoundingClientRect(); | ||
var body = document.body; | ||
@@ -22,6 +25,6 @@ var doc = document.documentElement; | ||
left: Math.round(box.left + scrollLeft - clientLeft), | ||
width: elem.offsetWidth, | ||
height: elem.offsetHeight | ||
width: el.offsetWidth, | ||
height: el.offsetHeight | ||
}; | ||
} | ||
//# sourceMappingURL=getOffsetRect.js.map |
@@ -7,3 +7,3 @@ interface Bounds { | ||
} | ||
export declare function getOffsetRect(elem: HTMLElement): Bounds; | ||
export declare function getOffsetRect(elem: HTMLElement | Text | null): Bounds; | ||
export {}; |
@@ -9,3 +9,5 @@ "use strict"; | ||
function getOffsetRect(elem) { | ||
if (typeof window === 'undefined') { | ||
var isElement = elem instanceof HTMLElement; | ||
if (typeof window === 'undefined' || !isElement) { | ||
return { | ||
@@ -19,3 +21,4 @@ top: 0, | ||
var box = elem.getBoundingClientRect(); | ||
var el = elem; | ||
var box = el.getBoundingClientRect(); | ||
var body = document.body; | ||
@@ -30,6 +33,6 @@ var doc = document.documentElement; | ||
left: Math.round(box.left + scrollLeft - clientLeft), | ||
width: elem.offsetWidth, | ||
height: elem.offsetHeight | ||
width: el.offsetWidth, | ||
height: el.offsetHeight | ||
}; | ||
} | ||
//# sourceMappingURL=getOffsetRect.js.map |
{ | ||
"name": "@vkontakte/vkjs", | ||
"version": "0.11.0", | ||
"version": "0.11.1", | ||
"description": "VK shared JS libs", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -8,4 +8,6 @@ interface Bounds { | ||
export function getOffsetRect(elem: HTMLElement): Bounds { | ||
if (typeof window === 'undefined') { | ||
export function getOffsetRect(elem: HTMLElement | Text | null): Bounds { | ||
const isElement = elem instanceof HTMLElement; | ||
if (typeof window === 'undefined' || !isElement) { | ||
return { | ||
@@ -19,3 +21,4 @@ top: 0, | ||
const box = elem.getBoundingClientRect(); | ||
const el = elem as HTMLElement; | ||
const box = el.getBoundingClientRect(); | ||
const body = document.body; | ||
@@ -31,5 +34,5 @@ const doc = document.documentElement; | ||
left: Math.round(box.left + scrollLeft - clientLeft), | ||
width: elem.offsetWidth, | ||
height: elem.offsetHeight, | ||
width: el.offsetWidth, | ||
height: el.offsetHeight, | ||
}; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
188942
2693