Sha256: 918599494ffd614f220555a967a8bb90abe0aa94672bd5c92e550eb0852ff445

Contents?: true

Size: 475 Bytes

Versions: 3

Compression:

Stored size: 475 Bytes

Contents

var animate = function(i, img) {
  var frameCount = $(img).attr("frameCount");
  var frameLength = $(img).attr("frameLength"); 
  var frameSide = $(img).attr("frameSide");  
  var margin = "margin-" + frameSide;

  var cont = 0;
  var rollImage = function() {
    $(img).css(margin, -1 * (cont*frameLength));  
    cont++;
    if(cont == frameCount){
      cont = 0;
    }   
  }
  setInterval(rollImage, 80);
}
$(function(){
  $("img[class^='animated']").each(animate); 
})

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sprite_animation-0.3.0 app/assets/javascripts/sprite_animation.js
sprite_animation-0.2.0 app/assets/javascripts/sprite_animation.js
sprite_animation-0.1.0 app/assets/javascripts/sprite_animation.js