Jump to content
Search Community

ericnguyen23

Members
  • Posts

    42
  • Joined

  • Last visited

Posts posted by ericnguyen23

  1. 11 hours ago, OSUblake said:

     

    Ha. Yes they did.

     

    I found a couple other questions related to this.

    https://stackoverflow.com/a/55996413/2760155

    https://stackoverflow.com/a/57102037/2760155

    https://stackoverflow.com/a/55105849/2760155

     

    In those answers, they create an array of createRef(), which requires extracting the current values into a new array to get the actual elements. Not sure which approach is the best one to use.

     

     

     

     

     

     

    Nice work digging up those threads!

     

    Two reasons why your first approach is better:

    1. Less code
    2. Adding additional cards requires adding additional createRef( ) 

     

    • Like 2
  2. 7 hours ago, OSUblake said:

    I think it might better to ask hooks related question on Stackoverflow instead of here. Like how to create an array of refs. There aren't too many people who are familiar with hooks over here.

     

    That said, I got it to work, but I don't know if that's the best way to create an array of refs.

     

     

     

     

     

     

    I did eventually post on Stackoverflow, but you actually came up with the solution, while other community took a tangent. Matter of fact, you guys have answered a bunch of my React related questions. 

     

    THIS was the part I was missing. Didn't realize I could reference an array this way. 

     

    let cardRef = useRef([]);

    Again, hats off to this community. I know this question is leans more heavily towards React but will come in handy to others as React is pretty popular. React + GSAP is a pretty amazing combo! 

    • Like 3
  3. Hey Guys,

     

    I'm trying to figure out how to apply StaggerFrom animation with my React functional component. You guys were able to help with Class component version as seen here

     

    I'm thinking I need to set an empty array as a variable, then reference each array element within ref attribute, but can't quit figure out the syntax as

    let cardRef[] = useRef(); 

    doesn't seem to work.

    See the Pen zYOdZYE by ericnguyen23 (@ericnguyen23) on CodePen

  4. 3 hours ago, PointC said:

    If you check the console you'll see that headingRedf is not the <h1>, but rather an object. This will make it move.

     

    
        tl[0].to(headingRedf.current, 1, {
          y: +30,
        }).to(headingRedf.current, 1, {
          y: 0,
        });

    You're also getting a console error about exports not being defined. That's all I can offer with my lack of React knowledge. Happy tweening.

    :)

     

    You may not know React, but you are pretty solid with JS! ?

     

    Everything makes total sense now! 

     

    • Like 3
  5. 15 minutes ago, PointC said:

    I don't know anything about React, but what you have wired up there is returning an array for the tl variable. A timeline is the first element in the array and then a function. This seems to fix it.

     

    
        tl[0].to(headingRedf, 1, {
          y: +30,
        }).to(headingRedf, 1, {
          y: 0,
        });

    Again, I have no knowledge of React so others will probably jump in with a proper solution.

     

     

    Thanks, that does render the content but animation doesn't run. I'll play around with it some more.

  6. Question (for those familiar w/ React and GSAP) regarding setting Timeline with functional components.

     

    I'm aware that to access DOM, I would have to reference and set animation like so, which works just fine:

    // creating state objects
    const [animation, setAnimation] = useState();
    
    // Set variable using useRef for functional component
    let headingRef = useRef(null);
    
    // add reference to the DOM element
    <h1 ref={element => {headingRef = element;}}>Hello</h1>  
    
    / // animate using useEffect hook and setAnimation 
    useEffect(() => {
        setAnimation(
          TweenMax.to(headingRef, 1, {
            css: {
              height: 120,
            },
          })
        );
    }, []);

     

    Now, what if I wanted to create a timeline. Do I just set it like so:

    let tl = new TimelineMax();

    Or do I need to store it in a state object?

  7. 2 hours ago, Dipscom said:

    Oh, look at this, it's a thread party! Whoop whoop whoop!

     

    So, I see the zooming in on Chrome and agree that is a jarring experience. It makes me think you have forgotten to add the meta tags for the zooming and scaling of the document. In fact, checking your original link, I don't see any of the metatags.

     

    If your are unfamiliar with codePen, press the settings button of your pen, look at the HTML tab and under the Stuff for <head> text area there's a button that says: "insert the most common viewport metatags". Click on that to add some common stuff, save your pen and check to see if that helps.

    Thanks, I've added this and the jumpy/jittery behavior is still there.  Let me explain what I'm experiencing:

    1. When I click on the name input box, browser jumps to bottom section.
    2. As I continue to scroll up and down, I also experience jittery animations. This again, likely due to Scrollmagic, so I'll take a look at css solution @ZachSaucier mentioned above.
  8. 4 minutes ago, Dipscom said:

    Hey @ericnguyen23,

     

    I'm on Android phone right now and was not able to see any unexpected jumping around. What phone are you using? What browser? I'm on a Nokia running Firefox.

     

    Do you have this issue if you open your example pen in 'Debug' mode? It will help us figure out if it's something to do with codePen.

     

     

    I'm on s8 Plus, Chrome browser. 

     

    Yes, same issues in debug view. Here's the debug link: https://s.codepen.io/ericnguyen23/debug/pozgdWz/jVApobzEWqZr

  9. 14 minutes ago, ZachSaucier said:

    Take away the z-index of .nav. 

     

    If you give it a z-index it will create its own stacking context, which prevents children from being placed behind it. See this post for more info.

     

    Happy tweening!

     

    Thanks Zach - although that works, it takes away the hovering functionality with subnav (because of the element below it). I'll look into more, hopefully I don't have to tear up my code too much! 

  10. 16 hours ago, Visual-Q said:

    Unfortunately I know nothing about react so I haven't even tried to work out what you intend with the useEffect function but this is a basic implementation of using paused:true on timeline and play and reverse in event handlers. Hopefully it will get you moving in the right direction.

     

     

     

     

    I'm a noob in React myself, actually a relative noob in modern web dev, but seems like I have to use `useEffect` for animations to work with a functional component. 

     

    This is what I was looking for, thanks! 

     

    This is totally a side topic and not related to GSAP, but I'll throw it out there: How can I get my subnav to be positioned behind my main nav? 

  11. I'm back! 

    I've edited/updated my codepen since I'm developing a React menu: 

     

    So far, I've got the timeline to run (onLoad). Now how do I call it on mouseover and mouseleave? I've setup the mouseenter and mouseleave event handlers, but not sure how I'd go about calling the timeline. 

     

     

  12. 4 minutes ago, ZachSaucier said:

    Hey Eric.

     

    This is definitely possible! The setup depends on how you want it to animate. They key concept is that instead of adding a class, you'd use a tween to affect some properties of the drop down menu. Then when the menu/navigation has stopped being hovered, you tween it back to being hidden.

     

    Is there a specific part of this process that you're having trouble with?

     

    Not yet, for now at least. 

    I just wanted to verify this is possible. I'll go play with it now and if I have questions I'll come back.

×
×
  • Create New...