Jump to content
Search Community

Cassie last won the day on April 16

Cassie had the most liked content!

Cassie

Administrators
  • Posts

    4,919
  • Joined

  • Last visited

  • Days Won

    174

Posts posted by Cassie

  1. One bit of advice would be to scale the video up to the large size with css and then scale down with GSAP.

    But if it's working with ScrollTrigger in codepen and not on your own site that's a clue that something else (not GSAP) is the problem.

    Maybe you're trying to run too much JS at the same time, maybe your images or video files are too large. There could be many reasons.

    • Like 1
  2. Quote

    I'd thought I was just asking about having a child component's gsap animation reference a parent - which may not work in React without passing refs, but it *does* work with Gsap, React and Astro.

    Ok, I get what you're after, sorry that took a while. I got confused because you're talking about referencing a parent, which isn't really what's happening. At least not *just* directly referencing a parent.


    By not scoping your useGSAP hook your selectors are global. So they'll grab anything that's available to them in the DOM. Not just the parent. Literally anything that matches that selector that React has already rendered.

    Use at your own risk I guess. It's fine if you feel you've got a reliable idea of what's been rendered at the point that GSAP code runs, and if you're using selectors wisely, but it's not really the correct "React" way of doing things. (which is not a discussion to get into here 😂)
     

    Quote

    Just as a takeaway from this: Is it fair then to say that ScrollTrigger animations must be placed at *at least* the level of the component that contains the trigger?

    It's more "reacty" to keep your GSAP code in a parent and use a scope so that your selectors aren't global. Then you can drop your components anywhere without worry, which is kinda the point of React. Encapsulation.

    But you do you really. If you want to take the guardrails off and just make all your selectors global you can!

  3. I feel like Rodrigo attempted to address that. It's not really about scope at that point. Communicating UP the React tree is into ref land/passing callbacks and stuff. Unless I'm misunderstanding the question. Very possible, React makes my brain hurt.

    Quote

    Instead of that just have everything inside that Section component and create the ScrollTrigger instance inside that component. Creating the instance in the child component, while needing or using a selector from a parent component is a far more complex setup that you should avoid if possible, instead of having the code in the Box component have the code in the Section component.


    I think that's what he meant by this

    Quote

    You should get more knowledge on react components, components communication and state management, all react features that fall outside the scope of these free forums. 

    It's not a skill level callout, just advice on what to look into to find a solution


    Have you seen the component communication sections in the docs? Maybe there's something there that can help?
    https://gsap.com/resources/react-advanced#component-communication

  4. Hey Nick!

     

    Yesterday was a particularly busy day in the forums, so sorry if this came across as blunt. I'm pretty Rodrigo meant nothing by it.

    We struggle quite a bit over here with users asking for support with React related issues. React themselves don't have a forum, despite being so widely used and funded by facebook 🫠 Go figure. So it often falls on our very small team to try and help.

     

    We're not really React experts, but as it's so prevalent we've tried to learn so that we can help.  We've pretty much outlined ALL of our knowledge in these guides
    https://gsap.com/resources/React/

     

    We've also created the hook to try and help. We'll happily answer questions about how the hook works, or how cleanup works, or even about the GSAP API itself.

    But architectural questions about the best way to structure things in a particular framework involve a lot of domain knowledge, understanding of the codebase in question and a lot of higher level thinking. It's really not GSAP related at that point. That's why we suggest the reactiflux community in our react guide. That's a good place to have discussions about structure.
    https://www.reactiflux.com/


    As Rodrigo said earlier on

    Quote

    If I was you I'd avoid this setup and keep everything inside the same component in order to make your life easier. If you can't then this is more related to how these type of situations are handled in React rather than a GSAP related issue or even a scoping issue TBH.

    That sums it up really. We advise keeping it simple and if you can't it may be a good idea to talk to some React experts about how best to structure things.

    Sorry for coming off as rude, and sorry we can't help more here!

  5. The xy problem is a very common issue in support forums, both from the perspective of someone answering and someone asking. It's been very helpful for me to step back and ask, is this asking about the solution or the core goal.

    I just thought it would be helpful for you too.

    I don't know where you're seeing insulting or shaming. It's just a handy way to view phrasing questions. You may be reading between the lines a bit here.

     

    Anyway, have a nice day and I'm glad we found a solution.
     

  6. It's not a criticism, no need to defend yourself. Just an observation.

    The title of this post and your question focused on the issues you were facing with your attempted solution rather than the goal - so everyone got hyper focused in on the technicalities of trying to integrate motionPath with Flip, rather than the actual goal of curving the animation.

    I'm glad we got there, sometimes the most simple route is the right one.

  7. If you're not changing the x value all you could just add another tween to animate that?

    See the Pen WNWgdZV?editors=0010 by GreenSock (@GreenSock) on CodePen

     

    The box was invisible becasue there wasn't a background color defined, the previous codepen used an external stylesheet. How did you 'clone' it? If you just pressed 'fork' at the bottom it should have just copied everything exactly. This video shows where the fork button is
     

    • Like 1
  8. Hey! Just parachuting in here, but maybe we're focusing on the solution you've attempted instead of the problem you're trying to solve?

     

    This made me remember something that may be useful?

    Quote

    You appear to be thinking of a motionPath more like an ease (style of movement; a matter of pacing/timing which could be applied to any interpolation) rather than an actual set of coordinates. 



    Without using a motion path, another common animation pattern for curved motion is to animate the x and y values with different eases to get a curve.

    Check out this demo -

     

    See the Pen dyoxXaQ by snorkltv (@snorkltv) on CodePen

     

    This is useful because it's not trying to animate the element through set coordinates, it's more dynamic. There's a start and end and it's the ease that's handling time rather than position to make the path curved

     

    I needed to do a curved flip animation a while back and found out that you can separate out x and y and animate them individually with customProps. (undocumented right now because animating the properties in a flip animation is quite a rare need due to it's dynamic/transitionary nature) but if you want a curved path - it allows you to separate out the properties in the flip animation and ease them individually.

     

    See the Pen cc6a1577ab5d5ea8ab0722dc407a7929?editors=0010 by GreenSock (@GreenSock) on CodePen

     

    Maybe that will achieve the "scenic taxi route" for you?

     

    • Like 3
  9. This video is showing completely different functionality though. There's no layered panels here.

    In the video, the panel that the tree is in doesn't reveal the panel beneath it or get revealed by the panel above. It's just a normal scrolling page, then the tree gets pinned for a while. It feels like you're trying to mash together two very different things here. I'm not really sure how you're aiming to combine them?

    Maybe something like this is closer?

    See the Pen VwNBOQZ?editors=1010 by GreenSock (@GreenSock) on CodePen

  10. Lets hold off on stackblitz and refresh and React questions until this is actually working.

    So in order for each of the panel 'reveal' to work, each panel needs this setup in the scrollTrigger.

    trigger: panel,
    end: `top+=${window.innerHeight}`,
    pin: true,
    pinSpacing: false,


    If you change one of the panels to use the box as a trigger - like this, you're changing the functionality of the panels.

    trigger: ".box", //<= this is a change as i want to trigger it on itself, or at least not to the top of the panel
    scrub: true,
    start: `top+=${window.innerHeight} center`,
    pin: true,
    pinSpacing: false,

    You also got rid of the if/else statement so  as you say, you're adding nested pins to the panel with the box element now. 

    Maybe this helps? You can't do nested pinning, but you can animate elements within a pinned container and use nested elements as the trigger, as long as you state that they're within a pinned container...


    See the Pen MWRBdJr?editors=1010 by GreenSock (@GreenSock) on CodePen

    • Like 1
  11. Hi there, am I correct that the white space only appears during the resize? If so that's just the browser recalculating and adjusting the layout.

     

    I wouldn't see that as an issue. The only people that really resize browser windows are developers anyway! From years of bug testing websites and watching user journeys, the average user doesn't resize the browser, and if they do, they certainly don't care what the website looks like during resize. As long as the layout settles and is useable you're a ok.

    • Like 1
×
×
  • Create New...