Created
July 4, 2016 03:26
-
-
Save nishinoshake/959c60c2800190c9be0cea6260a149f9 to your computer and use it in GitHub Desktop.
背景ズラして連続スプライト画像
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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