File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,8 @@ function FloatingHeader({ header }: Props) {
21
21
const [ height , setHeight ] = useState ( 0 )
22
22
const [ marginTop , setMarginTop ] = useState ( 0 )
23
23
24
+ const isHome = checkIsHome ( pathname )
25
+
24
26
useEffect ( ( ) => {
25
27
if ( ! blockRef . current ) return
26
28
setHeight ( blockRef . current . clientHeight )
@@ -56,11 +58,19 @@ function FloatingHeader({ header }: Props) {
56
58
setVisible ( false )
57
59
}
58
60
59
- setMarginTop ( Math . min ( 0 , - 1 * height + transitionPoint . current - scrollTop ) )
61
+ const marginTopMax = 0
62
+ const marginTopMin = isHome ? - 112 : - 64
63
+
64
+ const calculatedMarginTop = Math . min (
65
+ marginTopMax ,
66
+ - 1 * height + transitionPoint . current - scrollTop ,
67
+ )
68
+
69
+ setMarginTop ( Math . max ( calculatedMarginTop , marginTopMin ) )
60
70
61
71
direction . current = nextDirection
62
72
prevScrollTop . current = scrollTop
63
- } , [ height ] )
73
+ } , [ height , isHome ] )
64
74
65
75
useEffect ( ( ) => {
66
76
document . addEventListener ( 'scroll' , onScroll )
@@ -69,7 +79,6 @@ function FloatingHeader({ header }: Props) {
69
79
}
70
80
} , [ onScroll ] )
71
81
72
- const isHome = checkIsHome ( pathname )
73
82
return (
74
83
< div
75
84
className = { cx ( 'block' ) }
You can’t perform that action at this time.
0 commit comments