Skip to content

Commit 2ce147c

Browse files
authored
Merge pull request #155 from FunTechInc/v2-restart-fix
add container parameter to useGUI function to control GUI layout
2 parents 2b96b2f + e265401 commit 2ce147c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

utils/useGUI.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { useCallback, useEffect, useState } from "react";
1+
import { useCallback, useEffect, useState, RefObject } from "react";
22
import GUI from "lil-gui";
33

4-
export const useGUI = (setupGUI: (gui: GUI) => void, title?: string) => {
4+
export const useGUI = (setupGUI: (gui: GUI) => void, title?: string, container?: RefObject<HTMLDivElement>) => {
55
const [gui, setGUIState] = useState<GUI | null>(null);
66

77
useEffect(() => {
@@ -10,6 +10,8 @@ export const useGUI = (setupGUI: (gui: GUI) => void, title?: string) => {
1010
closeFolders: true,
1111
width: 240,
1212
title,
13+
autoPlace: container?.current ? false : true,
14+
container: container?.current || undefined,
1315
});
1416
setGUIState(newGui);
1517
setupGUI(newGui);
@@ -20,7 +22,7 @@ export const useGUI = (setupGUI: (gui: GUI) => void, title?: string) => {
2022
setGUIState(null);
2123
}
2224
};
23-
}, [gui, setupGUI, title]);
25+
}, [gui, setupGUI, title, container]);
2426

2527
const updateDisplays = useCallback(() => {
2628
gui?.folders.forEach((folder) =>

0 commit comments

Comments
 (0)