forked from shama/letswritecode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
40 lines (36 loc) · 798 Bytes
/
index.js
File metadata and controls
40 lines (36 loc) · 798 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// setTimeout(function () {
// console.log('im called after 1s');
// }, 1000);
// var count = 0;
// var interval = setInterval(function () {
// if (count > 5) {
// clearInterval(interval);
// }
// count++;
// console.log('every 1s');
// }, 1000);
// function getBear (callback) {
// setTimeout(function () {
// console.log('got bear');
// callback();
// }, 3000 * Math.random());
// }
//
// function poll () {
// getBear(function () {
// setTimeout(poll, 1000);
// });
// }
// poll();
var bear = new Image();
bear.src = '/bear.jpg';
bear.style.position = 'absolute';
document.body.appendChild(bear);
var delta = 0;
var amount = 50;
function draw () {
bear.style.left = amount * Math.sin(delta) + 'px';
delta += .1;
requestAnimationFrame(draw);
}
draw();