Reputation: 1
I am trying to animate this SVG logo on my website, but it doesn't seem to work. Here is the code:
import { useEffect, useRef } from 'react'
import gsap from 'gsap-trial'
import DrawSVGPlugin from 'gsap-trial/DrawSVGPlugin'
import LogoS from '../../../assets/images/logo-s.png'
import './index.scss'
const Logo = () => {
const bgRef = useRef()
const outlineLogoRef = useRef()
const solidLogoRef = useRef()
useEffect(() => {
gsap.registerPlugin(DrawSVGPlugin)
gsap
.timeline()
.to(bgRef.current, {
duration: 1,
opacity: 1,
})
.from(outlineLogoRef.current, {
drawSVG: "0%",
duration: 20,
})
gsap.fromTo(
solidLogoRef.current,
{
opacity: 0,
},
{
opacity: 1,
delay: 4,
duration: 4,
}
)
}, [])
return (
<div className="logo-container" ref={bgRef}>
<img
className="solid-logo"
ref={solidLogoRef}
src={LogoS}
alt="JavaScript, Developer"
/>
<svg
width="559pt"
height="897pt"
version="1.0"
viewBox="0 0 559 897"
xmlns="http://www.w3.org/2000/svg"
>
<g
className="svg-container"
transform="translate(0 457) scale(.1 -.1)"
fill="none"
>
<path
ref={outlineLogoRef}
d="*svg paths*"
/>
</g>
</svg>
</div>
)
}
export default Logo
The CSS code for the SVG has the necessary stroke values so I'm pretty sure that isn't the problem:
.svg-container {
stroke: #ffd700;
stroke-width: 10;
}
What I see on the page is the logo fading in (the opacity going from zero to one) after a while, so it seems to be skipping that animation step.
Upvotes: -1
Views: 35