Skip to content
This repository was archived by the owner on Apr 18, 2024. It is now read-only.

Commit 9e35cba

Browse files
committed
Rewrite from getIntersection to direct find
1 parent 1d5e561 commit 9e35cba

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

e2e/tests/helpers.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -142,20 +142,18 @@ const polygonKonva = async (points, done) => {
142142
try {
143143
const delay = () => new Promise(resolve => setTimeout(resolve, 10));
144144
const stage = window.Konva.stages[0];
145-
const firstCoords = points[0];
146145
for (let point of points) {
147146
stage.fire("click", { evt: { offsetX: point[0], offsetY: point[1] } });
148147
await delay();
149148
}
150149

150+
// this works in 50% runs for no reason; maybe some async lazy calculations
151+
// const firstPoint = stage.getIntersection({ x, y });
152+
153+
// Circles (polygon points) redraw every new click so we can find it only after last click
154+
const lastPoint = stage.find("Circle").slice(-1)[0];
155+
const firstPoint = lastPoint.parent.find("Circle")[0];
151156
// for closing the Polygon we should place cursor over the first point
152-
const [x, y] = firstCoords;
153-
const firstPoint = stage.getIntersection({ x, y });
154-
if (!firstPoint) {
155-
const getInfo = t => [t.className, t.x(), t.y()].join(" ");
156-
const allPoints = window.Konva.stages[0].find("Circle").map(getInfo);
157-
return done(`First point [${x}, ${y}] was not found (${allPoints})`);
158-
}
159157
firstPoint.fire("mouseover");
160158
await delay();
161159
// and only after that we can click on it

0 commit comments

Comments
 (0)