美文网首页
jq插件jcarousellite_1.0.1c4.js

jq插件jcarousellite_1.0.1c4.js

作者: 爱熬夜的疯子 | 来源:发表于2018-09-05 17:42 被阅读0次

jcarousellite_1.0.1c4.js是一个常用的插件,其实官网说的很清楚了。
但是我在使用的时候,发现如果频繁调用获取数据接口,滚动就有问题了。
问题:滚动的速度特别快 ,我的代码贴出来了,没问题吧!!!

$.ajax({ url:url,
        type:'get',
        dataType: 'json',
        success:function(data){
            if(data.code==0){
              $('.content-name-li ul li').length>0 && (function(){
                 $(".content-name-li").jCarouselLite({
                    vertical: true,
                    hoverPause:true,
                    visible: 1,
                    auto:1000,
                    speed:1000
                 })
              })();
    },
    error:function(data){
      unlock('获取失败!');
    }
});

看看源码吧,肯定是定时器控制的伐,频繁调用接口,打乱了定时器。所以我们要给一个状态。不要让定时器傻傻分不清楚。

var timeStatus = true;
$.ajax({ url:url,
        type:'get',
        dataType: 'json',
        success:function(data){
            if(data.code==0){
              if(timeStatus){
                $('.content-name-li ul li').length>0 && (function(){
                   $(".content-name-li").jCarouselLite({
                      vertical: true,
                      hoverPause:true,
                      visible: 1,
                      auto:1000,
                      speed:1000
                   })
              })();
              }
              
    },
    error:function(data){
      unlock('获取失败!');
    }
});

其他地方调用接口的时候,设置timeStatus = false
完美.jpeg

相关文章

网友评论

      本文标题:jq插件jcarousellite_1.0.1c4.js

      本文链接:https://www.haomeiwen.com/subject/xmyrwftx.html