-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
11 changed files
with
312 additions
and
86 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
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,57 @@ | ||
import { Box } from '@mui/material' | ||
import { useEffect, useRef, useState } from 'react' | ||
|
||
type Props = { | ||
children: React.ReactNode | ||
} | ||
|
||
export default function StaticPanel({ children }: Props) { | ||
const [isFixed, setIsFixed] = useState(true) | ||
const [scrollPosition, setScrollPosition] = useState(0) | ||
|
||
useEffect(() => { | ||
const handleScroll = () => { | ||
const position = window.scrollY | ||
setScrollPosition(position) | ||
} | ||
|
||
window.addEventListener('scroll', handleScroll) | ||
return () => { | ||
window.removeEventListener('scroll', handleScroll) | ||
} | ||
}, []) // Empty dependency array ensures the effect runs only on mount and unmount | ||
|
||
const containerRef = useRef<HTMLDivElement>(null) | ||
const mapBottom = document.getElementById('map-cell-0') | ||
|
||
if (containerRef.current && mapBottom) { | ||
const makeFixed = | ||
window.innerHeight - mapBottom.getBoundingClientRect().bottom < 295 | ||
|
||
if (!makeFixed && isFixed) { | ||
setIsFixed(false) | ||
} | ||
|
||
if (makeFixed && !isFixed) { | ||
setIsFixed(true) | ||
} | ||
} | ||
|
||
return ( | ||
<Box display={'flex'} justifyContent="center"> | ||
<Box | ||
paddingLeft={'100px'} | ||
paddingRight={'100px'} | ||
sx={{ | ||
position: isFixed ? 'fixed' : 'absolute', | ||
zIndex: 20, | ||
width: '100%', | ||
...(isFixed ? { bottom: 100 } : { marginTop: '30px' }), | ||
}} | ||
ref={containerRef} | ||
> | ||
{children} | ||
</Box> | ||
</Box> | ||
) | ||
} |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
Oops, something went wrong.