-
Is it possible to listen to when the window is maximized or minimized using the Tauri JS API? I found nothing in the documentation that would allow me to do this. Do I have to resort to periodically polling |
Beta Was this translation helpful? Give feedback.
Answered by
Looky1173
Dec 21, 2022
Replies: 3 comments 1 reply
-
I've managed to solve my problem with |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Looky1173
-
can you show me how you did it? |
Beta Was this translation helpful? Give feedback.
1 reply
-
Or as a hook... export function useIsMaximized() {
const [isMaximized, setIsMaximized] = useState<boolean>(false);
useEffect(() => {
function handleResize() {
appWindow.isMaximized().then((newState) => setIsMaximized(newState));
}
handleResize();
const unlisten = appWindow.listen('tauri://resize', async () => {
handleResize();
});
return () => {
unlisten.then((u) => u());
};
}, []);
return { isMaximized };
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've managed to solve my problem with
appWindow.onResized
which fires when a window is maximized/minimized.