fix: 解决首页报错offsetWidth undefined
This commit is contained in:
@@ -4,8 +4,7 @@ import { ScrollTrigger } from 'gsap/ScrollTrigger'
|
|||||||
import './index.less'
|
import './index.less'
|
||||||
import SvgIcon from '@/components/SvgIcon/SvgIcon.tsx'
|
import SvgIcon from '@/components/SvgIcon/SvgIcon.tsx'
|
||||||
const HomeIndex: React.FC = () => {
|
const HomeIndex: React.FC = () => {
|
||||||
useEffect(() => {
|
const animationFunction=()=>{
|
||||||
document.body.classList.add('body')
|
|
||||||
if (!CSS.supports('animation-timeline: scroll()')) {
|
if (!CSS.supports('animation-timeline: scroll()')) {
|
||||||
// const SPAN = 'max(45vw, 260px)';
|
// const SPAN = 'max(45vw, 260px)';
|
||||||
const CONFIG = [
|
const CONFIG = [
|
||||||
@@ -189,8 +188,13 @@ const HomeIndex: React.FC = () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
useEffect(() => {
|
||||||
|
document.body.classList.add('body')
|
||||||
|
window.addEventListener('resize', animationFunction);
|
||||||
return () => {
|
return () => {
|
||||||
document.body.classList.remove('body')
|
document.body.classList.remove('body')
|
||||||
|
window.removeEventListener('resize', animationFunction);
|
||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
return (
|
return (
|
||||||
|
Reference in New Issue
Block a user