Jump to content
Search Community

Scrolltrigger breaks on resize

Maniak Development test
Moderator Tag

Go to solution Solved by OSUblake,

Recommended Posts

Hello, I have an issue that I haven't been able to fix. I have a scrolltrigger moving some pinned images right to left and the final images has to stay close to the edge of the screen. The issue is when there is a resize it seems that the scrolltrigger just breaks and I don't know exactly how to handle the resize. I try to kill the tween and created again but it does nothing.

 

Edit. It looks like the codepen is not working, don't know why. I had to open it and then click run to make it work.

See the Pen porZXXr by godhandkiller (@godhandkiller) on CodePen

Link to comment
Share on other sites

  • Solution
17 minutes ago, hmontelongo said:

Edit. It looks like the codepen is not working, don't know why. I had to open it and then click run to make it work.

 

You are using export, which won't work in a normal CodePen.

 

You don't need to listen for resizes as ScrollTrigger does that automatically. For values that are dynamically calculated, you should use function based values.

 

this.timeline = gsap.timeline(scrollTrigger:{
                trigger: this.$slidesContainer,
                start: 'top+=80px top+=350px',
                end: () => '+=' + $(this.$slides[0]).width() * this.$slides.length,
                scrub: 0.1,
                invalidateOnRefresh: true
            })
              .to(this.$slides, {
            x: () => {
                let slideWidth = $(this.$slides[0]).width()
                let slidesWidth = slideWidth * this.$slides.length
               return -(slidesWidth + 380)
            },
            ease: 'none'            
        })

 

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

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...