Commit 8a147535 authored by jalf's avatar jalf

Clamp mouseclick coordinates to target element bounds

parent 49d5cee9
......@@ -298,7 +298,9 @@ Util.getEventPosition = function (e, obj, scale) {
if (typeof scale === "undefined") {
scale = 1;
}
return {'x': (docX - pos.x) / scale, 'y': (docY - pos.y) / scale};
var x = Math.max(Math.min(docX - pos.x, obj.width-1), 0);
var y = Math.max(Math.min(docY - pos.y, obj.height-1), 0);
return {'x': x / scale, 'y': y / scale};
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment