Jump to content
Search Community

widen image on scroll

jaacoubi test
Moderator Tag

Recommended Posts

I want to widen an image on scroll by using gsap , but I am using React I didn't know how to implement it , and didn't successfully manage to do it , any idea how to fix this ?

I have tried something like this , but didn't work either :

 <ArticleWrapper ref={ref}>
        <img id='grow' className='image' src={Img} alt='Image' />
</ArticleWrapper>
  const ref = useRef(null);
 useEffect(() => {
    const element = ref.current;
    scrollTrigger: {
    trigger: "#grow",
    scrub: 1.5,
    start: "top center",
    end: "+=400",
    ease: "power1.out"
  },
      {
       duration: 1,
  scale: 1
      }
    );
  }, []);

 

See the Pen dyvyxRp?editors=0010 by kendallstrautman (@kendallstrautman) on CodePen

Link to comment
Share on other sites

32 minutes ago, elegantseagulls said:

I think you are getting confused as to what React is doing and what GSAP is doing...

 

This will be helpful:

 

 

32 minutes ago, elegantseagulls said:

I think you are getting confused as to what React is doing and what GSAP is doing...

 

This will be helpful:

 

what should I use in order to make the scrolling animation behavior in React ?

Link to comment
Share on other sites

It's pretty tough to troubleshoot without a minimal demo - 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 React starter template on CodeSandbox. 

 

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

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