Gereltod
Gereltod

Reputation: 2234

JS Sprite animation on Chrome

I'm making some sprite animation (easter egg) on my site. Its working well on Mozilla. But on Chrome its not working. Problem is everytime I use $("img").attr('src', 'new_path') its downloading new image (not from cache). How I solve it?

Please open it on Mozilla then type "holycow", and you will see how it must work. Then open it on Chrome.

http://html5.maniac.mn/

Javascript: http://html5.maniac.mn/js/liukang.js

Upvotes: 0

Views: 463

Answers (1)

Kai Qing
Kai Qing

Reputation: 18833

You're going about this the wrong way, sir. You need to make a sprite sheet and offset the background-position instead. Otherwise you'll get flickering in at least one browser. If you need an example I can update this answer.

Here's a sample of this in action:

http://www.wrightonwrong.com/

hover over the depressed stick figure guy. You can view the js source and any image assets to see how I did it here.

a slightly more elaborate version here: http://www.innercirclestyles.com/

Upvotes: 1

Related Questions