Skip to content

Commit

Permalink
add stop control
Browse files Browse the repository at this point in the history
  • Loading branch information
jlongster committed May 24, 2011
1 parent 5eace76 commit fae1e7d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ <h3>
CSS Effects:
<div><input type="checkbox" name="border"> Border</div>
<div><input type="checkbox" name="off"> Off</div>
<div><input type="checkbox" name="stop"> Stop</div>

<pre class="off-code">.off:nth-of-type(2n) {
top: 100px;
Expand Down
29 changes: 23 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ $(function() {
}
}

var timer;

function bind_controls() {
var c = $('#controls');
c.find('input[name=border]').click(function() {
Expand Down Expand Up @@ -56,6 +58,26 @@ $(function() {
c.find('.off-code').hide();
}
});

c.find('input[name=stop]').click(function() {
if(this.checked) {
clearInterval(timer);
timer = null;
}
else if(!timer) {
timer = start_loop();
}
});
}

var rot = 0.0;

function start_loop() {
return setInterval(function() {
update(rot);
rot += 0.05;
frame();
}, 50);
}

make_renderer('canvas');
Expand All @@ -66,12 +88,7 @@ $(function() {
// dom3d.current_renderer().use_matrix();
// dom3d.current_renderer().use_refs();

var rot = 0.0;
setInterval(function() {
update(rot);
rot += 0.05;
frame();
}, 50);
timer = start_loop();

bind_controls();
update_controls();
Expand Down

0 comments on commit fae1e7d

Please sign in to comment.