dqmnueuu459279 2015-01-15 18:07
浏览 77
已采纳

带有prev / next的jquery自动滑块

i saw many posts with sliders using jquery/css.

i have a database from where i retrieve links of images and text.

i want to create a recent feed section of a slider type with automatic scrolling, like the ones seen on many sites.

I saw this example on stackoverflow http://jsfiddle.net/uXn2p/1/

It uses overflow hidden property and animates the sliding.

I added this piece of code to make it automated.

setInterval(function() {
 $(".list").delay( 800 ).animate({scrollLeft: "+=330"}, 'slow', "swing");
  $(".list").delay( 800 ).animate({scrollLeft: "+=330"}, 'slow', "swing");


 $(".list").delay( 800 ).animate({scrollLeft: "-=990"}, 'slow', "swing");

    }, 2000);

But once this animation begins the prev/next buttons stop working. I know i am doing something wrong that isn't valid with jquery.

What is it? How do i correct it?

  • 写回答

2条回答 默认 最新

  • dsfovbm931034814 2015-01-15 20:20
    关注

    I have tweaked your code quite a bit, but I think I got what you are looking for. I went off this example: http://jsfiddle.net/n8B2k/1/

    I changed the html to be this below, but it looks the same. I also added the functionality to remove the "prev" button when it was all the way to the left and remove the "more" button when all the way to the right (you can remove or modify it if you don't like it).

    <div id="slidesContainer">
      <div id="slideInner">
        <div class="slide">
            <div class="box">1</div>
            <div class="box">2</div>
            <div class="box">3</div>
        </div>
        <div class="slide">
            <div class="box">4</div>
            <div class="box">5</div>
            <div class="box">6</div>
        </div>
        <div class="slide">
            <div class="box">7</div>
            <div class="box">8</div>
            <div class="box">9</div>
        </div>
      </div>
    </div>
    <div id="slideShow">
      <button class="control" id="leftControl">prev</button>
      <button class="control" id="rightControl">more</button>
    </div>
    

    It's not the exact animation you used, but you can modify it.

    Here is my fiddle: http://jsfiddle.net/uXn2p/124/

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置