function getOffset (node) {
let result = {
top: 0,
left: 0
}
if (!node.getClientRects().length) {
return;
}
if (window.getComputedStyle(ele)['display'] === 'none') {
return result
}
result = node.getBoundingClientRect()
var docElement = node.ownerDocument.documentElement
return {
top: result.top + window.pageYOffset - docElement.clientTop,
left: result.left + window.pageXOffset - docElement.clientLeft
}
}
网友评论