ericnguyen23
Content Type
Profiles
Forums
Store
Blog
Product
Showcase
FAQ
Downloads
Posts posted by ericnguyen23
-
-
-
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!
- 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
-
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!
- 3
-
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.
-
Hi Guys,
I'm trying to do a simple animation with a React project using functional component. I'm getting this error:
QuoteUncaught TypeError: tl.to is not a function
My timeline and DOM elements are defined and running my timeline within useEffect( ) so not sure why I'm getting that error.
Any help is appreciated.
See the Pen GRKrexJ by ericnguyen23 (@ericnguyen23) on CodePen
-
Thanks @Rodrigo This helps.
I'll set my timeline up like this now:
const [tl] = useState(new TimelineMax());
- 1
-
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?
-
Thanks @PointC and @ZachSaucier - You've armed me with a couple of good options!
- 1
-
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:
- When I click on the name input box, browser jumps to bottom section.
- 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.
-
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
-
There's a strange behavior with GSAP/Scrollmagic with input fields on Mobile Phones (I'm testing on Android): When I scroll down to the form, click on the first input box, the browser jumps down to the bottom of next section. Works fine on desktop.
See the Pen pozgdWz by ericnguyen23 (@ericnguyen23) on CodePen
-
I'm trying to create a sticky scroll where paragraph appears as user scrolls down.
The timeline and scrollmagic both work, but once I try to pass GSAP timeline into Scrollmagic's setTween, it breaks. You can see I commented the line of code out // .setTween(this.tl)
**This is a React Project**
See the Pen pozgdWz by ericnguyen23 (@ericnguyen23) on CodePen
-
I ended up taking all z-indexes out of play, even on subnav ( since a negative z-index limited me to a lot of functionality on that element) and positioned it absolute and animating visibility and height which achieved the effect I was looking for.
GSAP is amazing!
See the Pen rXBgNR?editors=0110 by ericnguyen23 (@ericnguyen23) on CodePen
- 2
-
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!
-
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?
-
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.
-
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. -
I'm working on a "mega menu" type dropdown menu and currently just using CSS transition, triggered by JS mouseenter event. I eventually want to make it drop down. Is it possible to create the drop-down animation via Greensock as a timeline, then calling that timeline on mouseenter?
See the Pen rXBgNR by ericnguyen23 (@ericnguyen23) on CodePen
-
1 minute ago, Visual-Q said:
Sorry I misread I thought you were talking about the white edge on the left I updated to take care of both issues.
Oh sweet, thanks. I had the overflow-x but within the containing div and not body.
-
hmm, I'm interacting w/ yours and still can scroll right.
-
3 minutes ago, Visual-Q said:
Remove the margin on the body
in css add body{margin:0}
Thanks but that didn't work.
-
I'm attempting to animate images from outside viewport/browser in (sort of like an image carousel), but it creates extra space to the right. Anyone know how to animate similarly w/o that space? I tried overflow-x: hidden but that didn't do anything. thanks!
See the Pen ydNgmR?editors=0110 by ericnguyen23 (@ericnguyen23) on CodePen
-
Stagger Animation with React Functional Components
in GSAP
Posted
Nice work digging up those threads!
Two reasons why your first approach is better: