Created
June 17, 2013 18:10
-
-
Save suneo3476/5798906 to your computer and use it in GitHub Desktop.
要素がsetIntervalでアニメーションする。
This file contains 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
<!DOCTYPE HTML> | |
<html lang="ja"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>アニメーション</title> | |
</head> | |
<body> | |
<div id="foo" style="position: absolute">This is sample.</div> | |
<script> | |
var elem = document.getElementById('foo'); | |
var frame = 0; | |
setInterval(function () { | |
frame += 1; | |
elem.style.left = frame * 10 + 'px'; | |
}, 100); // 100ミリ秒ごとに10ピクセルずつ右に移動していく | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment