notice-scroll.js 583 Bytes
/**
 * 公告栏目滚动
 * bikai kai.bi@yoho.cn
 */

var $ = require('yoho-jquery');

function noticeScroll(selecter, time) {
    var $notice = $(selecter || '.notice'),
        $noticeItem = $notice.find('.notice-item'),
        count = $noticeItem.length,
        i = 1;

    time = time || 3000;

    if (count > 1) {
        setInterval(function() {
            if (i >= count) {
                i = 0;
            }

            $noticeItem.fadeOut();
            $notice.find('.item-' + i).fadeIn();
            i++;
        }, time);
    }
}

module.exports = noticeScroll;