-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5a6938e
commit b81d926
Showing
18 changed files
with
971 additions
and
936 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/component/1d-2d/components/ViewerResponsiveWrapper.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { useEffect } from 'react'; | ||
import type { ReactNode } from 'react'; | ||
|
||
import { useDispatch } from '../../context/DispatchContext.js'; | ||
import { useViewportSize } from '../../hooks/useViewportSize.js'; | ||
|
||
interface ViewerResponsiveWrapperProps { | ||
width: number; | ||
height: number; | ||
children: ReactNode; | ||
} | ||
|
||
export function ViewerResponsiveWrapper(props: ViewerResponsiveWrapperProps) { | ||
const dispatch = useDispatch(); | ||
const { width, height, children } = props; | ||
const size = useViewportSize(); | ||
|
||
useEffect(() => { | ||
if (!size) { | ||
dispatch({ type: 'SET_DIMENSIONS', payload: { width, height } }); | ||
} | ||
}, [width, height, dispatch, size]); | ||
|
||
return children; | ||
} |
Oops, something went wrong.