Skip to content

Commit e2803b4

Browse files
committed
cancel recurssive raf on inspect-off
1 parent 30188c7 commit e2803b4

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

src/core/web/inspect-element/inspect-state-machine.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,22 @@ import { getCompositeComponentFromElement, hasValidParent } from './utils';
1212

1313
export type States =
1414
| {
15-
kind: 'inspecting';
16-
hoveredDomElement: HTMLElement | null;
17-
propContainer: HTMLDivElement;
18-
}
15+
kind: 'inspecting';
16+
hoveredDomElement: HTMLElement | null;
17+
propContainer: HTMLDivElement;
18+
}
1919
| {
20-
kind: 'inspect-off';
21-
propContainer: HTMLDivElement;
22-
}
20+
kind: 'inspect-off';
21+
propContainer: HTMLDivElement;
22+
}
2323
| {
24-
kind: 'focused';
25-
focusedDomElement: HTMLElement;
26-
propContainer: HTMLDivElement;
27-
}
24+
kind: 'focused';
25+
focusedDomElement: HTMLElement;
26+
propContainer: HTMLDivElement;
27+
}
2828
| {
29-
kind: 'uninitialized';
30-
};
29+
kind: 'uninitialized';
30+
};
3131

3232
export const INSPECT_TOGGLE_ID = 'react-scan-inspect-element-toggle';
3333
export const INSPECT_OVERLAY_CANVAS_ID = 'react-scan-inspect-canvas';
@@ -73,6 +73,7 @@ export const createInspectElementStateMachine = () => {
7373
}
7474

7575
const clearCanvas = () => {
76+
cancelAnimationFrame(animationId)
7677
ctx.save();
7778

7879
ctx.setTransform(1, 0, 0, 1, 0, 0);
@@ -333,7 +334,7 @@ export const createInspectElementStateMachine = () => {
333334
if (
334335
adjustedX >= currentLockIconRect.x &&
335336
adjustedX <=
336-
currentLockIconRect.x + currentLockIconRect.width &&
337+
currentLockIconRect.x + currentLockIconRect.width &&
337338
adjustedY >= currentLockIconRect.y &&
338339
adjustedY <= currentLockIconRect.y + currentLockIconRect.height
339340
) {

0 commit comments

Comments
 (0)