Jump to content
Search Community

Pinned elements are not responsive

kvncnls test
Moderator Tag

Recommended Posts

Hi!

So I have a simple pin animation, but it's not responsive.
Codebase is in Nextjs, so you'll see an `itemRef.current` here to target a UI element.
 

    let imageTL = gsap.timeline({
      scrollTrigger: {
        trigger: itemRef.current.querySelector(
          ".col.image-container"
        ),
        start: "center center",
        end: "85% 25%",
        id: "imageTL",
        scrub: 1,
        pin: true,
        pinSpacing: false,
        onLeave: (self) => self.kill(false, true),
      },
    });

    imageTL.fromTo(
      itemRef.current.querySelector(
        ".col.image-container .image"
      ),
      { opacity: 0, scale: 3 },
      {
        opacity: 1,
        scale: 1,
        duration: 5,
        ease: "power4.inOut",
      }
    );

 

Link to comment
Share on other sites

It's pretty tough to troubleshoot without a minimal demo - the issue could be caused by CSS, markup, a third party library, your browser, an external script that's totally unrelated to GSAP, etc. Would you please provide a very simple CodePen or CodeSandbox that demonstrates the issue? 

 

Please don't include your whole project. Just some colored <div> elements and the GSAP code is best (avoid frameworks if possible). See if you can recreate the issue with as few dependancies as possible. If not, incrementally add code bit by bit until it breaks. Usually people solve their own issues during this process! If not, then at least we have a reduced test case which greatly increases your chances of getting a relevant answer.

 

Here's a starter CodePen that loads all the plugins. Just click "fork" at the bottom right and make your minimal demo

See the Pen aYYOdN by GreenSock (@GreenSock) on CodePen

 

If you're using something like React/Next/Nuxt/Gatsby or some other framework, you may find CodeSandbox easier to use. 

 

Once we see an isolated demo, we'll do our best to jump in and help with your GSAP-specific questions. 

Link to comment
Share on other sites

3 hours ago, GSAP Helper said:

It's pretty tough to troubleshoot without a minimal demo - the issue could be caused by CSS, markup, a third party library, your browser, an external script that's totally unrelated to GSAP, etc. Would you please provide a very simple CodePen or CodeSandbox that demonstrates the issue? 

 

Please don't include your whole project. Just some colored <div> elements and the GSAP code is best (avoid frameworks if possible). See if you can recreate the issue with as few dependancies as possible. If not, incrementally add code bit by bit until it breaks. Usually people solve their own issues during this process! If not, then at least we have a reduced test case which greatly increases your chances of getting a relevant answer.

 

Here's a starter CodePen that loads all the plugins. Just click "fork" at the bottom right and make your minimal demo

 

 

If you're using something like React/Next/Nuxt/Gatsby or some other framework, you may find CodeSandbox easier to use. 

 

Once we see an isolated demo, we'll do our best to jump in and help with your GSAP-specific questions. 

Hey @GSAP Helper! Thanks for the quick reply!
I can't set up the codepen right now, so I'll try it out tomorrow.

Question though: Could it be the scale? I'm doing a fromTo() of scale: 3 to scale:1.
I have a feeling that this could be it... If so, how can I make it responsive?

Link to comment
Share on other sites

15 minutes ago, kvncnls said:

Question though: Could it be the scale? I'm doing a fromTo() of scale: 3 to scale:1.
I have a feeling that this could be it... If so, how can I make it responsive?

Sorry, I don't really understand what you're asking. Typically "responsive" means that it adjusts based on the width/height of the viewport. Animating the scale has nothing to do with something being responsive. Very difficult to understand or answer without a minimal demo. I'm sure once you provide that it'll become clearer. 

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