Guys I have a question. I have this code but it's not working with Scrolltrigger.matchmedia
I mean when I remove the mathMedia everything works fine but with this nothing works fine! I use Locomotive Scroll BTW!
gsap.registerPlugin(ScrollTrigger);
ScrollTrigger.matchMedia({
"(min-width: 800px)": function() {
const imgwr = document.querySelector(".small-image-wr")
gsap.utils.toArray(".small-image-wr").forEach((imgwr, i) => {
imgwr.img = imgwr.querySelector(".img-4");
gsap.from(imgwr.img, {
yPercent: 10,
});
gsap.to(imgwr.img, {
yPercent: -10,
ease: "none",
scrollTrigger: {
trigger: imgwr,
scroller: ".sections-wr",
scrub: true,
invalidateOnRefresh: true
}
});
});
},
"(min-width: 800px)": function() {
const projectimg = document.querySelector(".project-image")
gsap.utils.toArray(".project-image").forEach((projectimg, i) => {
projectimg.img = projectimg.querySelector(".img-5");
gsap.from(projectimg.img, {
yPercent: 10,
});
gsap.to(projectimg.img, {
yPercent: -10,
ease: "none",
scrollTrigger: {
trigger: projectimg,
scroller: ".sections-wr",
scrub: true,
invalidateOnRefresh: true
}
});
});
}
});