I have two problems.
1) I'm trying to fade in images by staggering them. Fade in part works but stagger part is not. Where is the problem, am I doing a logic mistake?
Is using a hook approach like in the https://codesandbox.io/s/xph6v?file=/src/useTextReveal.js would fix this?
export function FadeInStagger({ children }) {
const el = useRef()
useEffect(() => {
const animations = []
const elements = gsap.utils.toArray(el.current.children)
elements.forEach((element) => {
const animation = gsap.from(element, {
duration: 1,
opacity: 0,
ease: "none",
stagger: 0.3,
scrollTrigger: {
trigger: element,
markers: true,
start: "center 60%",
end: "center 60%",
toggleActions: "play play reverse reverse",
}
})
animations.push(animation)
})
return () => {
animations.forEach((animation) => animation.scrollTrigger.kill())
}
}, [])
return <div className="brands-images" ref={el}>{children}</div>
}
<FadeInStagger>
<img src="/images/brands/samsung.png" alt="Samsung" />
<img src="/images/brands/trt.png" alt="TRT" />
<img src="/images/brands/altinpusula.png" alt="Altın Pusula" />
<img src="/images/brands/aydindogan.png" alt="Aydın Doğan Vakfı" />
<img src="/images/brands/yildizholding.png" alt="Yıldız Holding" />
</FadeInStagger>
2) And it seem's like animated elements breaks some css attributes.
For example "img:hover { opacity: 1 }" is not working
but "img:hover { background-color: red } works. Is this a bug?
.brands-images {
width: 100%;
display: flex;
justify-content: space-around;
align-items: center;
img {
transition: 0.3s;
opacity: .5;
max-width: 100%;
height: auto;
}
img:hover {
opacity: 1;
background-color: green;
}
}