Skip to content

Commit

Permalink
Remove window change detection to update status after exiting full sc…
Browse files Browse the repository at this point in the history
…reen (#471)
  • Loading branch information
nini22P authored Mar 2, 2024
1 parent 24b7330 commit c33e2a0
Showing 1 changed file with 0 additions and 22 deletions.
22 changes: 0 additions & 22 deletions packages/webgal/src/hooks/useFullScreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export function useFullScreen() {
const dispatch = useDispatch();
const fullScreen = userDataState.optionData.fullScreen;
const isEnterGame = GUIState.isEnterGame;
let currentWindowHeight = window.innerHeight;

useEffect(() => {
switch (fullScreen) {
Expand All @@ -33,25 +32,4 @@ export function useFullScreen() {
}
}, [fullScreen]);

/**
* 通过窗口高度变化判断是否退出全屏,并更改全屏状态
*/
useEffect(() => {
const isExitingFullScreen = () => {
if (
fullScreen === fullScreenOption.on &&
isEnterGame &&
currentWindowHeight > window.innerHeight &&
currentWindowHeight !== window.innerWidth // 防止旋转屏幕时退出全屏
) {
dispatch(setOptionData({ key: 'fullScreen', value: fullScreenOption.off }));
setStorage();
}
currentWindowHeight = window.innerHeight;
};
window.addEventListener('resize', isExitingFullScreen);
return () => {
window.removeEventListener('resize', isExitingFullScreen);
};
}, [fullScreen, currentWindowHeight]);
};

0 comments on commit c33e2a0

Please sign in to comment.