Make container optional in L.DomUtil.getMousePosition(). Addresses #1926

This commit is contained in:
Scooter Wadsworth 2013-08-01 00:15:53 -04:00
parent c311fc967d
commit ea044c8312

View File

@ -137,8 +137,13 @@ L.DomEvent = {
docEl = document.documentElement,
x = e.pageX ? e.pageX - body.scrollLeft - docEl.scrollLeft: e.clientX,
y = e.pageY ? e.pageY - body.scrollTop - docEl.scrollTop: e.clientY,
pos = new L.Point(x, y),
rect = container.getBoundingClientRect(),
pos = new L.Point(x, y);
if (!container) {
return pos;
}
var rect = container.getBoundingClientRect(),
left = rect.left - container.clientLeft,
top = rect.top - container.clientTop;