Skip to content

Commit

Permalink
fix: replace screen.orientation with mediaQuery.
Browse files Browse the repository at this point in the history
  • Loading branch information
morganney committed Jan 18, 2024
1 parent aac2593 commit 2289e3d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.tgz
*.zip
dist
node_modules
coverage
Expand Down
5 changes: 3 additions & 2 deletions packages/ui/src/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ interface LayoutProps {
children: ReactNode
}

const orientationMql = window.matchMedia('(orientation: landscape)')
const Layout: FC<LayoutProps> = ({ children }) => {
const location = useLocation()
const { mode } = useTheme()
Expand Down Expand Up @@ -45,14 +46,14 @@ const Layout: FC<LayoutProps> = ({ children }) => {
if (map) {
map.on('move', moveListener)
map.on('moveend', moveEndListener)
screen.orientation.addEventListener('change', orientationListener)
orientationMql.addEventListener('change', orientationListener)
}

return () => {
if (map) {
map.off('move', moveListener)
map.off('moveend', moveEndListener)
screen.orientation.removeEventListener('change', orientationListener)
orientationMql.removeEventListener('change', orientationListener)
}
}
}, [map])
Expand Down

0 comments on commit 2289e3d

Please sign in to comment.