This commit is contained in:
Knut Sveidqvist
2020-07-21 11:15:42 +02:00
parent a6ec038189
commit 211d6f4005
2 changed files with 27 additions and 6 deletions

View File

@@ -16,10 +16,15 @@ function intersectPolygon(node, polyPoints, point) {
var minX = Number.POSITIVE_INFINITY;
var minY = Number.POSITIVE_INFINITY;
polyPoints.forEach(function(entry) {
minX = Math.min(minX, entry.x);
minY = Math.min(minY, entry.y);
});
if (typeof polyPoints.forEach === 'function') {
polyPoints.forEach(function(entry) {
minX = Math.min(minX, entry.x);
minY = Math.min(minY, entry.y);
});
} else {
minX = Math.min(minX, polyPoints.x);
minY = Math.min(minY, polyPoints.y);
}
var left = x1 - node.width / 2 - minX;
var top = y1 - node.height / 2 - minY;