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

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

function noticeScroll(selecter, time) {
    let $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;