-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: space에서 Subspace 생성 및 Subspace 노드 구현 (#157)
* feat: subspace node 추가 * feat: context 변화에 따라 재렌더링하도록 개선 * refactor: autofit 로직 별도 훅으로 분리 * chore: 더 이상 사용되지 않는 mock 데이터 삭제
- Loading branch information
Showing
7 changed files
with
151 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { RefObject, useEffect, useState } from "react"; | ||
|
||
export default function useAutofit<T extends Element>( | ||
container: RefObject<T> | T | undefined, | ||
) { | ||
const [size, setSize] = useState({ width: 0, height: 0 }); | ||
|
||
useEffect(() => { | ||
if (!container) { | ||
return undefined; | ||
} | ||
|
||
const containerRef = | ||
"current" in container ? container : { current: container }; | ||
|
||
function resizeStage() { | ||
const container = containerRef.current; | ||
|
||
if (!container) { | ||
return; | ||
} | ||
|
||
const width = container.clientWidth; | ||
const height = container.clientHeight; | ||
|
||
setSize({ width, height }); | ||
} | ||
|
||
resizeStage(); | ||
|
||
// NOTE: ResizeObserver를 도입할 것을 고려할 것 | ||
window.addEventListener("resize", resizeStage); | ||
return () => { | ||
window.removeEventListener("resize", resizeStage); | ||
}; | ||
}, [container]); | ||
|
||
return size; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters