Thanks i'll try that and report back.
I want to use such function as an option for my slideViewer plugin
wich basically creates a way to slide a set of images contained in an
unordered list.
Since the list is static (the first one is the first you see in the
gallery) i thought it would be nice to let the user randomize the list
so the order is never the same.
I'm working on the new version of slideViewer and i would like to let
it fade too, not only slide.
this is the page with the "old" attempt.
 
http://www.gcmingati.net/wordpress/wp-content/lab/jquery/imagestrip/imageslide-plugin.html

ciao Thanks!
GC

On Sep 6, 4:05 pm, Renaud <[EMAIL PROTECTED]> wrote:
> On 6 sep, 09:02, GianCarlo Mingati <[EMAIL PROTECTED]>
> wrote:
>
> > ok, it is better to have the images in an array, and then construct
> > the list.
> > But is there a way with jquery of changing the order of a list?
> > GC
>
> Here is a idea. That's a function based on the fisher-yates shuffle
> (thanks to perldoc perlfaq4).
>
> Pass it a jquery object that contains your li. (or you could extend
> jquery with it)
>
> --<snip>--
>
> function scramble(a) {
>     var i = a.size();
>     if (!i) return false;
>     while (--i) {
>         var j = Math.floor(Math.random() * (i+1));
>         var tmp = a.slice(i, i+1);
>         a.slice(j, j+1).after(tmp).insertAfter(tmp);
>
>     }
>
> }
>
> $(document).ready(function() { scramble($('ul#foo li')); });
>
> --</snip>--
>
> Regards,
> Renaud Drousies

Reply via email to