Skip to content

Instantly share code, notes, and snippets.

@nishinoshake
Created July 4, 2016 03:26
Show Gist options
  • Save nishinoshake/959c60c2800190c9be0cea6260a149f9 to your computer and use it in GitHub Desktop.
Save nishinoshake/959c60c2800190c9be0cea6260a149f9 to your computer and use it in GitHub Desktop.
背景ズラして連続スプライト画像
Index.flipImage = function() {
var index = 0;
var column = 5;
var fps = 30;
var length = 70;
var width = 150;
var height = 150;
(function render() {
var x = - (index % column) * width;
var y = - Math.floor(index / column) * height;
$('.graph').css({backgroundPosition: x + 'px ' + y + 'px'});
index++;
if ( index < length ) {
setTimeout(render, 1000 / fps);
}
})();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment