This code sequences the appearance of three bits of text:
function omen() {
$('#north').delay(1600).animate({opacity:'1.0'}, 2400, function() {
$('#east').delay(2400).animate({opacity:'1.0'}, 2400, function() {
$('#west').delay(800).animate({opacity:'1.0'}, 2400, function() {
// etc...// });
});
});
}
I'd like to make the delays a random amount, within certain parameters, eg
var randly = [ 10, 50, 100, 200, 400, 800, 1200 ]
dly = Math.floor(Math.random() *randly.length);
So: can you do something like this with jQ:
$('#north').delay('dly').animate({opacity:'1.0'}, 2400 ?
Later:
yep you can: you make the random choice a function, then you have to insert that function name into the brackets after '.delay':
function dl(){
var pause = [ 8000, 12000 ]
dlay = Math.floor(Math.random() * pause.length);
return pause[dlay];
}
function omen() {
$('#north').delay(dl()).animate({opacity:'1.0'}, 2400, function() {
not
$('#north').delay('dl()') ... this gets treated as zero.
Couple of updates:
1. This doesn't work with hide() and show(), but does with animate()
2. Tried var D = dl() for the animation function: doesn't work.