Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I animate though a PNG sequence using jQuery (either by scrolling or triggered animation) [closed]

More and more I am seeing an effect where pngs are loaded into a series of DIVs (or one div) and then sequenced though frame by frame either based on button click or based on scroll. I've tried to peek at the code, and I understand that javascript is doing the heavy lifting, but I'm still a bit lost, are there any tutorials on this technique? examples?

example of animation (multiple div) http://atanaiplus.cz/index_en.html:

example of animation (one div): http://www.hyundai-veloster.eu/

example of scrolling animation: http://discover.store.sony.com/tablet/#design/ergonomics

like image 533
user379468 Avatar asked Mar 12 '12 15:03

user379468


People also ask

How can use a animate () method in jQuery?

The animate() method performs a custom animation of a set of CSS properties. This method changes an element from one state to another with CSS styles. The CSS property value is changed gradually, to create an animated effect. Only numeric values can be animated (like "margin:30px").

How you can use jQuery to animate a flash to the button?

Pure jQuery solution. var flash = function(elements) { var opacity = 100; var color = “255, 255, 20” // has to be in this format since we use rgba var interval = setInterval(function() { opacity -= 3; if (opacity How can use jQuery to animate a flash to the button? var randomNumber = Math. floor(Math.

What does show () do in jQuery?

jQuery Effect show() Method The show() method shows the hidden, selected elements. Note: show() works on elements hidden with jQuery methods and display:none in CSS (but not visibility:hidden).


2 Answers

you just want to swap out the src attribute using a setInterval timer

var myAnim = setInterval(function(){
  $(".myImageHolder").attr('src', nextImage);
}, 42);

The trick is how you generate nextImage. This largely depends on the naming conventions of your images, or which direction you wish the animation to run in

Update

Or use a plugin

like image 111
Mild Fuzz Avatar answered Sep 24 '22 19:09

Mild Fuzz


Perhaps instead of switching between different images, use the spriting technique described in this question: How to show animated image from PNG image using javascript? [ like gmail ]

like image 40
Zugbo Avatar answered Sep 23 '22 19:09

Zugbo