fix: 解决首页报错offsetWidth undefined

This commit is contained in:
landaiqing
2024-05-06 01:52:39 +08:00
parent e8daca608a
commit 7b1fbbf733

View File

@@ -4,8 +4,7 @@ import { ScrollTrigger } from 'gsap/ScrollTrigger'
import './index.less'
import SvgIcon from '@/components/SvgIcon/SvgIcon.tsx'
const HomeIndex: React.FC = () => {
useEffect(() => {
document.body.classList.add('body')
const animationFunction=()=>{
if (!CSS.supports('animation-timeline: scroll()')) {
// const SPAN = 'max(45vw, 260px)';
const CONFIG = [
@@ -189,8 +188,13 @@ const HomeIndex: React.FC = () => {
},
})
}
}
useEffect(() => {
document.body.classList.add('body')
window.addEventListener('resize', animationFunction);
return () => {
document.body.classList.remove('body')
window.removeEventListener('resize', animationFunction);
}
}, [])
return (