mirror of
https://github.com/trafficlunar/blockmatic.git
synced 2026-06-28 14:44:12 +00:00
feat: resizable tool settings window
This commit is contained in:
parent
c8cccd8bf7
commit
acfd638d2c
4 changed files with 77 additions and 16 deletions
|
|
@ -267,24 +267,30 @@ function Canvas() {
|
|||
};
|
||||
|
||||
useEffect(() => {
|
||||
const container = stageContainerRef.current;
|
||||
if (!container) return;
|
||||
|
||||
const resizeCanvas = () => {
|
||||
if (stageContainerRef.current) {
|
||||
setStageSize({
|
||||
width: stageContainerRef.current.offsetWidth,
|
||||
height: stageContainerRef.current.offsetHeight,
|
||||
});
|
||||
}
|
||||
setStageSize({
|
||||
width: container.offsetWidth,
|
||||
height: container.offsetHeight,
|
||||
});
|
||||
};
|
||||
|
||||
const resizeObserver = new ResizeObserver(resizeCanvas);
|
||||
resizeObserver.observe(container);
|
||||
|
||||
resizeCanvas();
|
||||
return () => resizeObserver.disconnect();
|
||||
}, [stageContainerRef]);
|
||||
|
||||
useEffect(() => {
|
||||
setBlocks(welcomeBlocksData);
|
||||
|
||||
window.addEventListener("resize", resizeCanvas);
|
||||
window.addEventListener("keydown", onKeyDown);
|
||||
window.addEventListener("keyup", onKeyUp);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener("resize", resizeCanvas);
|
||||
window.removeEventListener("keydown", onKeyDown);
|
||||
window.removeEventListener("keyup", onKeyUp);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue