Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
shiyiya committed Aug 10, 2024
1 parent 744856e commit 0309d1e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/index/src/components/layout/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useEffect, PropsWithChildren, Suspense } from 'react'
import { Route, RouteProps } from 'wouter'
import { debounce } from '@web/shared/utils/schedulers'
import Header from '../header'
import './index.scss'

Expand All @@ -9,15 +10,15 @@ const IndexLayout: React.FC<PropsWithChildren<any>> = (props) => {
useEffect(() => {
const header = document.querySelector('.upv-header__bar')!

const scrollHandler = (_: Event) => {
const scrollHandler = debounce((_: Event) => {
const scrollTop = $root.scrollTop

if (scrollTop >= 222) {
header.classList.add('fixed-header')
} else {
header.classList.remove('fixed-header')
}
}
}, 200)

$root.addEventListener('scroll', scrollHandler)
return () => {
Expand Down

0 comments on commit 0309d1e

Please sign in to comment.