Simple JQuery Fade ticker

后端 未结 4 1592
暖寄归人
暖寄归人 2021-01-24 16:18

I\'ve looked at multiple tickers and they are all far to weighted. I\'m after a very simple fadeIn() fadeOut() JQuery ticker for a list of elements to display titles.

         


        
4条回答
  •  生来不讨喜
    2021-01-24 16:33

    I did a very simple fader, very light weight. used it for images but changed it for divs:

    Script

    var aniSpd01 = 1000;
    var fadeSpd01 = 1000;
    
    $(function() {
        var startIndex = 0;
        var endIndex = $('#aniHolder div').length;
        $('#aniHolder div:first').fadeIn(fadeSpd01);
    
        window.setInterval(function() {
        $('#aniHolder div:eq(' + startIndex + ')').delay(fadeSpd01).fadeOut(fadeSpd01);
            startIndex++;
            $('#aniHolder div:eq(' + startIndex + ')').fadeIn(fadeSpd01);
    
            if (endIndex == startIndex) startIndex = 0;
        }, aniSpd01);
    });
    

    HTML

    Story 1
    Story 2
    Story 3

    CSS

    #aniHolder {width:640px; height:480px; }
    #aniHolder div {position:absolute; width:640px; height:480px; display:none;}
    

提交回复
热议问题