Jump to content
Search Community

Using sprite sheets to reduce file size in GSAP banner animations

sreid test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hello,

 

In the article, Solutions for Banner Ads in the Post-Flash World, posted on your site, it mentions that "Sprite sheets can be used to combine images", hence cutting down on the number of files in your final delivery.

 

I have tried to convert a GSAP banner animation that works perfectly with multiple, separate images in the "img" folder, to one that utilizes a Sprite Sheet.

 

The images are not part of an image sequence for say animating a character of sorts.

 

 

Using the sprite sheet, and the associated CSS that was generated in Fireworks, I am able to get the images to show up when previewed in a browser, but they do not animate, as they did when I had all separate images in my "img" folder.

 

Do you have a tutorial, or example file that can demonstrate how to utilize a Sprite Sheet in a GSAP animations, outside of image sequences?

 

It would be greatly appreciated!!

 

Link to comment
Share on other sites

The concept is basically:

  • Combine all your images into one big one
  • For each image, create a <div> with the background-image set to that big image, set overflow:hidden, and then use the background-position to move it into the correct spot so that only that [sub-]image is showing. 
  • Animate the  <div> as you normally would the <img> 

Does that help? 

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