Making a Jquery shuffle Gallery

前提是你 提交于 2019-12-04 04:54:07

问题


I'm trying to do a shuffle slideshow, like this this site. It's a gallery with shuffle and fade but I have only this code:

<div class="slideshow">    
     <img src="http://davy0324.netne.net/dummys/dummy1.jpg">
     <img src="http://davy0324.netne.net/dummys/dummy2.jpg">
     <img src="http://davy0324.netne.net/dummys/dummy3.jpg">
     <img src="http://davy0324.netne.net/dummys/dummy4.jpg">
     <img src="http://davy0324.netne.net/dummys/dummy5.jpg">
</div>

Can you help me please? I've dealt with shuffles codes but they start with a button, but I don't want buttons, I want a automatic gallery, with repeated indefinitely like in the website.


回答1:


Did you mean this (Using jQuery)

$(function(){
    (function(){
        var imgs=$('.slideshow img');
        var i=0;
        function shuffle()
        {
            $(imgs[i]).fadeIn(2000, function(){
                i=(i < imgs.length-1) ? (i+1) : 0;
                setTimeout(function(){
                    $('.slideshow img').fadeOut(2000);
                    shuffle();
                }, 2000);
            });
        }
        shuffle();
    })();
});​

DEMO.

Update: May be you want a random ordered image animation like this one.



来源:https://stackoverflow.com/questions/12232007/making-a-jquery-shuffle-gallery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!