Skip to content

Commit 4034ea3

Browse files
author
Cooper Maruyama
authored
[useWindowSize()] Visual Viewport Support (#234)
1 parent 60a6913 commit 4034ea3

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

packages/window-size/src/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export interface DebouncedWindowSizeOptions {
1111
}
1212

1313
const win = typeof window === 'undefined' ? null : window
14+
const wv = win && typeof win.visualViewport !== 'undefined' ? win.visualViewport : null
1415
const getSize = () =>
1516
[
1617
document.documentElement.clientWidth,
@@ -30,6 +31,7 @@ export const useWindowSize = (
3031
const setSize = (): void => setDebouncedSize(getSize)
3132

3233
useEvent(win, 'resize', setSize)
34+
useEvent(wv, 'resize', setSize)
3335
useEvent(win, 'orientationchange', setSize)
3436

3537
return size

0 commit comments

Comments
 (0)