Merge pull request #1928 from scooterw/get_mouse_position_fix

Make container optional in L.DomUtil.getMousePosition(). Addresses #1926
This commit is contained in:
Vladimir Agafonkin 2013-07-31 23:50:10 -07:00
commit 16db077b2a

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;