jaacoubi Posted June 23, 2022 Share Posted June 23, 2022 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 More sharing options...
elegantseagulls Posted June 23, 2022 Share Posted June 23, 2022 1 hour ago, jaacoubi said: 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 } ); }, []); You don't have a gsap tween in this. 1 Link to comment Share on other sites More sharing options...
jaacoubi Posted June 23, 2022 Author Share Posted June 23, 2022 Just now, elegantseagulls said: You don't have a gsap tween in this. What do you mean by a gsap tween ? Link to comment Share on other sites More sharing options...
elegantseagulls Posted June 23, 2022 Share Posted June 23, 2022 1 minute ago, jaacoubi said: What do you mean by a gsap tween ? gsap.timeline({...}) Link to comment Share on other sites More sharing options...
jaacoubi Posted June 23, 2022 Author Share Posted June 23, 2022 3 minutes ago, elegantseagulls said: gsap.timeline({...}) Can you add a snippet according to this problem , i will appreciate it if so ! Link to comment Share on other sites More sharing options...
elegantseagulls Posted June 23, 2022 Share Posted June 23, 2022 I think you are getting confused as to what React is doing and what GSAP is doing... This will be helpful: Link to comment Share on other sites More sharing options...
jaacoubi Posted June 23, 2022 Author Share Posted June 23, 2022 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 More sharing options...
GSAP Helper Posted June 23, 2022 Share Posted June 23, 2022 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now