Jump to content
Search Community

Pin/unpin element depending on device width

Cofkeb

Go to solution Solved by GreenSock,

Recommended Posts

Posted

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

 

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...