Skip to content

Commit

Permalink
fix: position not correct if stage pos changes
Browse files Browse the repository at this point in the history
  • Loading branch information
maitrungduc1410 committed May 26, 2023
1 parent 64f6c7e commit 9dcaede
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 44 deletions.
27 changes: 0 additions & 27 deletions .github/workflows/test.yml

This file was deleted.

18 changes: 2 additions & 16 deletions src/pages/panel/devtools/konvaDevtools.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type TKonva from "konva";
import { OutlineNode } from "../types";

export default function konvaDevtools() {
const win = window as any;
Expand All @@ -22,19 +21,6 @@ export default function konvaDevtools() {
return undefined;
}

function getRenderedBy(node: TKonva.Node) {
const trees: string[] = [];

const parent = node.getParent();
if (parent) {
trees.push(node.getParent().getClassName());
const result = getRenderedBy(parent);
trees.push(result);
}

return trees;
}

function Konva(): typeof TKonva {
return getGlobal("Konva");
}
Expand All @@ -44,8 +30,8 @@ export default function konvaDevtools() {
content(stageIndex = 0) {
return Konva().stages[stageIndex].getContent();
},
renderedBy(node: TKonva.Node) {
return getRenderedBy(node);
stage(stageIndex = 0) {
return Konva().stages[stageIndex];
},
};
}
5 changes: 4 additions & 1 deletion src/pages/panel/devtools/konvaDevtoolsOverlay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ export default function konvaDevtoolsOverlay(devtools: KonvaDevtools) {
function calibrateOverlay() {
const content = devtools.content(stageIndex);
const contentBounds = content.getBoundingClientRect();
overlayEl.style.transform = `translate(${contentBounds.x}px, ${contentBounds.y}px)`;
const stage = devtools.stage(stageIndex);
overlayEl.style.transform = `translate(${
contentBounds.x + stage.x()
}px, ${contentBounds.y + stage.y()}px)`;
}

let throttle = 0;
Expand Down

0 comments on commit 9dcaede

Please sign in to comment.