Merge pull request #1745 from jec006/calculate-y-mouse

Properly calculate the y position of the element when parent is positioned relatively
This commit is contained in:
Vladimir Agafonkin 2013-06-11 07:10:16 -07:00
commit 043fa18f1a

View File

@ -53,13 +53,16 @@ L.DomUtil = {
if (pos === 'relative' && !el.offsetLeft) {
var width = L.DomUtil.getStyle(el, 'width'),
maxWidth = L.DomUtil.getStyle(el, 'max-width');
maxWidth = L.DomUtil.getStyle(el, 'max-width'),
r = el.getBoundingClientRect();
if (width !== 'none' || maxWidth !== 'none') {
var r = el.getBoundingClientRect();
left += r.left + el.clientLeft;
}
//calculate full y offset since we're breaking out of the loop
top += r.top + (docBody.scrollTop || docEl.scrollTop || 0);
break;
}