File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # JavaScript Timers
2+
3+ > [ http://youtu.be/YmaFAKUFmp0 ] ( http://youtu.be/YmaFAKUFmp0 )
4+
5+ Install [ io.js] ( https://iojs.org/en/index.html ) .
6+
7+ Within this folder run the terminal command ` npm install ` to install the
8+ ` devDependencies ` .
9+
10+ Then run ` npm start ` to start up a development server on ` http://localhost:9966 `
Original file line number Diff line number Diff line change 1+ // setTimeout(function () {
2+ // console.log('im called after 1s');
3+ // }, 1000);
4+
5+ // var count = 0;
6+ // var interval = setInterval(function () {
7+ // if (count > 5) {
8+ // clearInterval(interval);
9+ // }
10+ // count++;
11+ // console.log('every 1s');
12+ // }, 1000);
13+
14+ // function getBear (callback) {
15+ // setTimeout(function () {
16+ // console.log('got bear');
17+ // callback();
18+ // }, 3000 * Math.random());
19+ // }
20+ //
21+ // function poll () {
22+ // getBear(function () {
23+ // setTimeout(poll, 1000);
24+ // });
25+ // }
26+ // poll();
27+
28+ var bear = new Image ( ) ;
29+ bear . src = '/bear.jpg' ;
30+ bear . style . position = 'absolute' ;
31+ document . body . appendChild ( bear ) ;
32+
33+ var delta = 0 ;
34+ var amount = 50 ;
35+ function draw ( ) {
36+ bear . style . left = amount * Math . sin ( delta ) + 'px' ;
37+ delta += .1 ;
38+ requestAnimationFrame ( draw ) ;
39+ }
40+ draw ( ) ;
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " js-timers" ,
3+ "version" : " 0.1.0" ,
4+ "description" : " " ,
5+ "main" : " index.js" ,
6+ "scripts" : {
7+ "start" : " budo index.js"
8+ },
9+ "author" : " Kyle Robinson Young <kyle@dontkry.com> (http://dontkry.com)" ,
10+ "license" : " MIT" ,
11+ "devDependencies" : {
12+ "budo" : " ^4.2.1"
13+ }
14+ }
You can’t perform that action at this time.
0 commit comments