Scrolling Offset Bug Fix

This commit is contained in:
chrillo 2011-07-28 10:36:21 +02:00
parent f58a1c7369
commit d4c73d2b57
2 changed files with 11 additions and 2 deletions

View File

@ -117,7 +117,7 @@ L.DomEvent = {
y = e.pageY ? e.pageY : e.clientY +
document.body.scrollTop + document.documentElement.scrollTop,
pos = new L.Point(x, y);
pos=pos.add(L.DomUtil.getCumulativeScroll(container))
return (container ?
pos.subtract(L.DomUtil.getCumulativeOffset(container)) : pos);
},

View File

@ -28,7 +28,16 @@ L.DomUtil = {
el = el.offsetParent;
} while (el);
return new L.Point(left, top);
},
},getCumulativeScroll: function(el){
var top=0,
left=0;
do {
top+=el.scrollTop || 0;
left+=el.scrollLeft || 0;
el=el.parentNode;
}while(el);
return new L.Point(left,top)
},
create: function(tagName, className, container) {
var el = document.createElement(tagName);