Jump to content
Search Community

Stack static image on top of the animation?

electricarts test
Moderator Tag

Recommended Posts

Hello,

 

I started to look into GSAP today. And what better way to learn than with a real, very simple example. 😉 It worked right away. But one question remains: I have an image which simply rotates infinitely. In the middle of the original image is a logo, but I don't want to animate this logo. What do you do as a best practice? Two separate images and the logo absolutely positioned above the animated graphic? 

 

Cheers
Mario

 

524355588_Screenshot2022-05-15at18_32_35.thumb.png.95889835c74aae43f3050445f2eab0ea.png

 

  • Like 1
Link to comment
Share on other sites

I think there's too much focus on 'best practices' nowadays - I tend to go with 'If it works it works'

Two images would work here, as would using an SVG with separate grouped elements. Whatever is easiest for you and whatever works is likely the best solution.

 

Glad to hear you're enjoying the tools!

  • Like 3
Link to comment
Share on other sites

Hey Cassie,

 

thanks a lot for your answer! At the moment 2 images were easier to implement. 🙂

 

I have created the original graphic and can create and export appropriate groups in the SVG. But how do i address only the group to animate in the animation? What would i have to look for in the docs?

  • Like 1
Link to comment
Share on other sites

Hey!

 

Ok, with that output I wouldn't suggest SVG - for some reason you've got lots of encoded PNG data of the color red in there, with clip paths added to create the shape of the dragon. That's going to make your markup really bloated.

If it was all SVG paths it would be much better - or even an image in the center.

This markup's been simplified down using SVGOMG (and a little manual tweaking) Even then - there's a lot of markup here because the text is all saved as paths instead of text elements.

See the Pen ExQZmQj by GreenSock (@GreenSock) on CodePen


 

Here's an article on SVG optimising
https://css-tricks.com/high-performance-svgs

 

 

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

@mvaneijgen My solution consisted of two images. The second, static SVG file was absolute positioned. The animation of the ring worked. I didn't want to mix this with the second possible solution (both graphics inside the SVG files), so I created the Codepen without GSAP code in the demo. Sorry, next time I'll make a demo right away. 

Link to comment
Share on other sites

@Cassie 

Thank you very much! The Phoenix did not come from me. I'll have to take a closer look and clean it up. 

The conversion of the text to paths comes from the use of the graphic in the print. Print is my "Kryptonite". I try to avoid as many sources of error as possible when printing. And embedded fonts are sometimes problematic in print. In SVG for web, text should not be converted to paths, right?

  • Like 1
Link to comment
Share on other sites

1 hour ago, electricarts said:

Ok. SVG reworked. File size now only 75 kb instead of 467 kb. 😉 But now another problem appears. The animation "jerks" and does not rotate as smooth as before. Did I forget or set some setting wrong?

Interesting, looks like the browser's struggling more with text elements than paths 

  • Like 1
Link to comment
Share on other sites

1 hour ago, electricarts said:

In Safari the animation runs smooth like butter. FF, Edge and Brave (all macOS) have problems. 

On Windows it's perfect for me in FF, but chugs pretty hard in Chrome and Edge. Browsers are such fun. 🤷‍♂️

 

Yeah - there are times when just exporting a .png or .webp is the preferred option. Using an SVG as a background image for a div can also help. Lots of little tips and tricks to try when the browser struggles.

 

Best of luck on the project.

:)

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...