Cofkeb Posted October 8, 2023 Posted October 8, 2023 Hello everyone, So basically I want to pin/unpin element depending on device width I have function for window resizing and I am changing the value of variable z inside the function, my question is how can I achieve this i tried with code below but it doesn't seem to work. window.addEventListener('resize', function(event) { var w = window.innerWidth; console.log(w); if(w>769){ z=true; } else{ z=false; } }, true); let tl = gsap.timeline({ scrollTrigger: { trigger: '.o-meni-desno', start: '30% center', end: '100% center', markers: true, toggleActions: 'restart none none none', scrub: 1, pin: function() { return z ? '.o-meni-levo' : false; }, pinSpacing: false, } });
Solution GreenSock Posted October 8, 2023 Solution Posted October 8, 2023 gsap.matchMedia() is perfect for this type of thing: See the Pen JjwwBxe by GreenSock (@GreenSock) on CodePen. Is that what you wanted?
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now