Skip to content

Commit 8b39e14

Browse files
committed
paint-round-corners: fix widget positions not updating on zoom/pan
Added a rAF loop (same pattern as paint-gradient-editor) that watches paper.view.matrix while the tool is active. When zoom or pan changes the matrix key, drawWidgets() is called to reposition all corner handles. The loop exits immediately when isToolActive is false, so there is no overhead once the tool is deactivated.
1 parent c26d7cf commit 8b39e14

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

addons/paint-round-corners/userscript.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,21 @@ export default async function ({ addon, msg }) {
719719
isToolActive = true;
720720
if (isSelectedClass) rcBtn.classList.add(isSelectedClass);
721721

722+
// Reposition widgets when the user zooms or pans (paper.view.matrix changes).
723+
// Mirrors the same rAF pattern used by paint-gradient-editor.
724+
let lastViewKey = "";
725+
const viewSyncLoop = () => {
726+
if (!isToolActive) return;
727+
const m = paper.view.matrix;
728+
const key = `${m.a.toFixed(3)},${m.tx.toFixed(1)},${m.ty.toFixed(1)}`;
729+
if (key !== lastViewKey) {
730+
lastViewKey = key;
731+
drawWidgets();
732+
}
733+
requestAnimationFrame(viewSyncLoop);
734+
};
735+
requestAnimationFrame(viewSyncLoop);
736+
722737
// Watch for tool switches (CHANGE_MODE), tab navigation, and undo/redo events.
723738
modeChangeHandler = ({ detail }) => {
724739
if (!isToolActive) return;

0 commit comments

Comments
 (0)