Skip to content

Commit

Permalink
fix: Hilo.getElementRect bug
Browse files Browse the repository at this point in the history
  • Loading branch information
06wj committed May 18, 2016
1 parent 17134c3 commit d1dda4a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/core/Hilo.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ return {
//this fails if it's a disconnected DOM node
var bounds = elem.getBoundingClientRect();
}catch(e){
bounds = {top:elem.offsetTop, left:elem.offsetLeft, width:elem.offsetWidth, height:elem.offsetHeight};
bounds = {top:elem.offsetTop, left:elem.offsetLeft, right:elem.offsetLeft + elem.offsetWidth, bottom:elem.offsetTop + elem.offsetHeight};
}

var offsetX = ((win.pageXOffset || docElem.scrollLeft) - (docElem.clientLeft || 0)) || 0;
Expand All @@ -269,14 +269,17 @@ return {
var padTop = (parseIntFn(styles.paddingTop) + parseIntFn(styles.borderTopWidth)) || 0;
var padRight = (parseIntFn(styles.paddingRight) + parseIntFn(styles.borderRightWidth)) || 0;
var padBottom = (parseIntFn(styles.paddingBottom) + parseIntFn(styles.borderBottomWidth)) || 0;

var top = bounds.top || 0;
var left = bounds.left || 0;
var right = bounds.right || 0;
var bottom = bounds.bottom || 0;

return {
left: left + offsetX + padLeft,
top: top + offsetY + padTop,
width: bounds.right - padRight - left - padLeft,
height: bounds.bottom - padBottom - top - padTop
width: right - padRight - left - padLeft,
height: bottom - padBottom - top - padTop
};
},

Expand Down

0 comments on commit d1dda4a

Please sign in to comment.