
previous

page 15
next
For resize() to work, we'll need to initialise g_side in globals.js.
var g_side=0;
And here's my resize function:
function resize() {
var side=45*vmin();
if (side!=g_side) setup();
}
var side=45*vmin();
if (side!=g_side) setup();
}
We should also cancel any timer that is in operation. The clearTimeout function is available for this purpose but we need to tell it which timer.
Three changes are necessary:
in globals.js:
var g_timer;
in one_step():
if (g_i<4) g_timer=setTimeout(one_step,200);
in setup():
function setup() {
clearTimeout(g_timer);
...
clearTimeout(g_timer);
...
previous
next