I'm trying to show some element with a random effect.
I store those functions in an array and try to get a random function from that array, but the functions seem to rum at the same time.
$.random_show = function(){
(function($) {
$.rand = function(arg) {
if ($.isArray(arg)) {
return arg[$.rand(arg.length)];
} else if (typeof arg === "number") {
return Math.floor(Math.random() * arg);
} else {
return 4; // chosen by fair dice roll
}
};
})(jQuery);
$.hide1 = function(){
alert ('right');
$('.feed_g_audio_holder_overlay').show("slide", { direction: "right" }, 700);
}
$.hide2 = function(){
alert ('left');
$('.feed_g_audio_holder_overlay').show("slide", { direction: "left" }, 700);
}
$.hide3 = function(){
alert ('down');
$('.feed_g_audio_holder_overlay').slideDown();
}
var hide_array = [$.hide1(), $.hide2(), $.hide3()];
return $.rand(hide_array);
}
Where am I getting this wrong?
Aucun commentaire:
Enregistrer un commentaire