Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function isPointOverPaper(mouseX, mouseY, paperContainer) {
const { left, top, width, height } = paperContainer.getBoundingClientRect();
const rect = new g.rect(left, top, width, height);
const point = new g.Point(mouseX, mouseY);
return rect.containsPoint(point);
}
function getClosestAnchorPoint(model, coords, group) {
const referencePoint = new g.Point(coords.x, coords.y);
return referencePoint.chooseClosest(getModelPortPoints(model, group));
}
function getModelPortPoints(model, group) {
const { x: modelX, y: modelY } = model.position();
const points = Object.values(model.getPortsPositions(group))
.map(({ x, y }) => new g.Point(modelX + x, modelY + y));
if (!points) {
const { x, y } = model.position();
const { width, height } = model.size();
points.push(new g.Point(x - (width / 2), y - (height / 2)));
}
return points;
}
.map(({ x, y }) => new g.Point(modelX + x, modelY + y));
if (!points) {