Jump to content
Search Community

Animate SVG Logo for a loading intro purpose (Draw SVG?)

vitor z test
Moderator Tag

Go to solution Solved by akapowl,

Recommended Posts

Hey guys, how is it going!? 😃

I'm still learning the GSAP basics with my first project using it, so i'm sorry if that's a dumb or frequent question.

 

I need to animate this svg logo for a loading intro just like the demo GIF. Is it possible? If yes, what's the best way or solution?

intro.gif.718fdd14c9812cf4448cba7d1d491b77.gif

 

Besides, i just joined GSAP club to use Draw SVG (don't know if is the best tool for this purpose). 

Here's the website that i'm working on it: http://thelotusyang.com/manutencao/

 

I'm originally an art director, so the only code i'm kinda familiar is css & html. I have to admit that i'm always struggling with js logics.

Thanks in advance 😃

Link to comment
Share on other sites

 

Hey @vitor z

 

Depending on how exactly it is you want things to be animated, you don't need the DrawSVGPlugin (well, if you want to initially draw the stroke of the SVG,it comes in pretty handy) - nonetheless it is good to have it :) 

 

Depending on how your SVG is set up (pre-preparing the SVG is always key to something like this), you could get it done with a pretty simple timeline.

 

Here is an example, tweening in the stroke of the star first, then the fill of the star, and then with a staggered tween, the circles

 

See the Pen 1713e961cec95b480fcf123ac1b6526c by akapowl (@akapowl) on CodePen

 

 

Hope this helps.

 

Cheers,

Paul

 

 

 

Edit:

And since you want this to run in a preloader-context, you could use GSAP's rich callback-system, to trigger whatever you need at whatever neccessary time. Here is an example where I split the fading in of the star and the circle-staggering into differnt timelines.

 

First, the star fades in - onComplete of that, the circlesTimeline starts playing.

 

onRepeat the circlesTimeline checks, if the variable contentIsLoaded (here for simulating the page-load-event - toggled after 10 seconds) is true. If it isn't, it keeps on repeating, If it is, it pauses (you could/should probably also kill it) and the initial fadeInTimeline is being reversed.

 

See the Pen 1c5aa2161864953023c0876a22470a05 by akapowl (@akapowl) on CodePen

 

 

  • Like 5
Link to comment
Share on other sites

Thanks for your reply, Paul!

 

Cool! As you said, seems to me that the pre-preparing of the SVG is my big challenge now. 

So, if I already have this svg file is it possible to use it or do you have any tips or tools about how can i redraw it correctly?

 

Cheers! 😃

Link to comment
Share on other sites

 

22 minutes ago, vitor z said:

So, if I already have this svg file is it possible to use it or do you have any tips or tools about how can i redraw it correctly?

 

You'd first have to get the SVG's code and insert it into your HTML for being able to animate it.

I don't think animating it is possible, with how you are adding it in via an img-tag.

 

You could get the code of your SVG either from your SVG editor app, or via Jake Archibald's SVG-OMG, put it inside your HTML and give it a test-ride yourself. If you are asking for an SVG-Editor - InkScape is pretty solid for an OpenSource and free to use vector-editing tool.

 

 

 

What's actually important here with regards to the animation, more precisely to the staggering, is the order, in which your equivalents to my circles appear in your html, from bottom to top. First to be shown should be on top, last being on bottom in that order.

 

So if you wanted to do it like in my demo, that would probably be the only thing to consider and you probably won't have to re-draw anything. If you wanted to animate the draw of the stroke of your center SVG, it would also be important, where the stroke has its start- and endpoints - and here maybe a rework of the SVG would be neccessary.

 

Give it a try and see if it works out in your scenario :) 

 

  • Like 3
Link to comment
Share on other sites

In addition to @akapowl's good info, I've written quite a bit about preparing assets, using a background rectangle and changing your start and end points. My training site has a few articles which may help.

 

https://www.motiontricks.com/better-svg-exports-make-animations-easier/

https://www.motiontricks.com/cut-your-path-start-points-in-adobe-illustrator/

https://www.motiontricks.com/use-background-rectangle-with-svg-exports/

https://www.motiontricks.com/adobe-illustrator-path-direction-quick-tip/

 

Hopefully there will be some helpful info in there for you.

 

Happy tweening.

:)

 

  • Like 5
Link to comment
Share on other sites

  • Solution

 

Yeah, that looks a bit wild, you'd have to format it a bit, to get it working.

Either in an editor - probably the easiest - or you could do it by hand.

 

A basic rule to follow in a case like this: 

When one path seems to contain multiple elements, everywhere you see a capital M inside that path, this is where the path of a new element starts.

 

I handled that for you, just to show it's possible to adjust it without a vector-editor app.

Also, I removed the fill that was set inline on all those paths, added some classes to the paths and some CSS.

 

And here, instead of tweening on the fill- and path- colors, the tweens are on the strokeOpacity and fillOpacity.

You see, that depending on the exact scenario there are multiple variations of how you can get where you want.

 

See the Pen c59a1a3fe9128b3b13efdc86be81daf7 by akapowl (@akapowl) on CodePen

 

 

Happy tweening :) 

 

 

  • Like 2
  • Thanks 1
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...