Merge pull request #1928 from scooterw/get_mouse_position_fix
Make container optional in L.DomUtil.getMousePosition(). Addresses #1926
This commit is contained in:
commit
16db077b2a
@ -137,8 +137,13 @@ L.DomEvent = {
|
|||||||
docEl = document.documentElement,
|
docEl = document.documentElement,
|
||||||
x = e.pageX ? e.pageX - body.scrollLeft - docEl.scrollLeft: e.clientX,
|
x = e.pageX ? e.pageX - body.scrollLeft - docEl.scrollLeft: e.clientX,
|
||||||
y = e.pageY ? e.pageY - body.scrollTop - docEl.scrollTop: e.clientY,
|
y = e.pageY ? e.pageY - body.scrollTop - docEl.scrollTop: e.clientY,
|
||||||
pos = new L.Point(x, y),
|
pos = new L.Point(x, y);
|
||||||
rect = container.getBoundingClientRect(),
|
|
||||||
|
if (!container) {
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
var rect = container.getBoundingClientRect(),
|
||||||
left = rect.left - container.clientLeft,
|
left = rect.left - container.clientLeft,
|
||||||
top = rect.top - container.clientTop;
|
top = rect.top - container.clientTop;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user