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,
}
});