为了账号安全,请及时绑定邮箱和手机立即绑定

慕课首页图片轮播用的什么插件

慕课首页图片轮播用的什么插件

_天蝎座的你_0 2016-05-03 09:12:23
jq想要实现,慕课首页图片轮播用什么插件
查看完整描述

5 回答

已采纳
?
vLiang

TA贡献47条经验 获得超30个赞

    // 首页轮播图-渐变
    (function(){
        var banner = $('.g-banner'),
            slides = banner.find('.banner-slide'),
            dotContainer = banner.find('.banner-dots'),
            dotTpl = '',
            dots,
            total = slides.length,
            index = -1,
            duration = 500,
            interval = 5000,
            timer = null;

        // 一张图 不执行轮播
        if(total == 1) {
            next();
            return;
        }

        dotTpl = '<span></span>';

        $.each(slides, function(i, el){
            dotContainer.append(dotTpl);
        });

        dots = dotContainer.find('span');

        function show(i){
            var cur = slides.filter('.slide-active');

            slides.stop(true, true);

            cur.removeClass('slide-active').fadeOut(600);

            slides.eq(i).addClass('slide-active').fadeIn(800);

            dots && dots.removeClass('active').eq(i).addClass('active');
        }
        function prev(){
            index--;

            index = index < 0 ? total - 1 : index;

            show(index);
        }

        function next(){
            index++;
            index = index > total - 1 ? 0 : index;

            show(index);
        }

        function autoPlay(){
            if(timer) clearInterval(timer);

            timer = setInterval(function(){
                next();
            }, interval);
        }

        banner.find('.banner-anchor').removeAttr('style');

        banner.on('click', '.prev', function(e){
            prev();
        }).on('click', '.next', function(e){
            next();
        }).on('click', '.banner-dots span', function(e){
            if($(this).hasClass('active')) return;

            var i = $(this).index();

            index = i;

            show(i);
        });

        banner.on('mouseenter', function(e){
            if(timer) clearInterval(timer);
        }).on('mouseleave', function(e){
            autoPlay();
        });

        next();

        autoPlay();

    })();

在首页的JS里面写的

查看完整回答
1 反对 回复 2016-05-03
?
一杯2块的奶茶

TA贡献226条经验 获得超75个赞


有点复杂

查看完整回答
反对 回复 2016-05-03
?
逗你玩而已

TA贡献38条经验 获得超6个赞


真够长的,有时间琢磨下

查看完整回答
反对 回复 2016-05-03
?
qq_好好学习_6

TA贡献19条经验 获得超13个赞

也许是自己写的呢?

查看完整回答
反对 回复 2016-05-03
  • 5 回答
  • 3 关注
  • 2104 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信