Skip to content

Commit 9e99d7b

Browse files
committed
refactor: timeout 개선
1 parent b7a6475 commit 9e99d7b

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/hooks/common/useKeyboardResize.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,25 @@ export const useKeyboardResize = () => {
99

1010
const handleVisualViewportChange = () => {
1111
clearTimeout(timeoutId);
12+
1213
timeoutId = setTimeout(() => {
1314
if (window.visualViewport) {
1415
const isKeyboardVisible = window.visualViewport.height < window.innerHeight;
16+
const newKeyboardHeight = isKeyboardVisible
17+
? window.innerHeight - window.visualViewport.height
18+
: 0;
19+
20+
if (isKeyboardVisible && newKeyboardHeight === 0) {
21+
setTimeout(() => {
22+
if (window.visualViewport) {
23+
setKeyboardHeight(window.innerHeight - window.visualViewport.height);
24+
}
25+
}, 300);
26+
} else {
27+
setKeyboardHeight(newKeyboardHeight);
28+
}
29+
1530
setKeyboardVisible(isKeyboardVisible);
16-
setKeyboardHeight(
17-
isKeyboardVisible ? window.innerHeight - window.visualViewport.height : 0,
18-
);
1931
}
2032
}, 100);
2133
};

0 commit comments

Comments
 (0)