Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/473.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在新幻灯片进入视图时移动滑块缩略图_Javascript_Jquery_Slider_Cycle_Jquery Cycle - Fatal编程技术网

Javascript 在新幻灯片进入视图时移动滑块缩略图

Javascript 在新幻灯片进入视图时移动滑块缩略图,javascript,jquery,slider,cycle,jquery-cycle,Javascript,Jquery,Slider,Cycle,Jquery Cycle,脚本:jQuery循环滑块: 在下一张幻灯片进入视图之前,我使用以下代码将滑块缩略图容器向左移动130像素。当到达最后一张幻灯片时,边距将重置为0px。这很好,但是容器在第三次滑动之前不会移动 这是我正在使用的代码: function onBefore(currElement, nextElement, opts, isFoward) { var currentslide = opts.currSlide + 1; if(currentslide == opts.slideCo

脚本:jQuery循环滑块:

在下一张幻灯片进入视图之前,我使用以下代码将滑块缩略图容器向左移动130像素。当到达最后一张幻灯片时,边距将重置为0px。这很好,但是容器在第三次滑动之前不会移动

这是我正在使用的代码:

function onBefore(currElement, nextElement, opts, isFoward) {
    var currentslide = opts.currSlide + 1; 
    if(currentslide == opts.slideCount) {
        jQuery(".slider-nav").animate({marginLeft: '0'});
    } else if(currentslide > 1 && currentslide != opts.slideCount) {
        jQuery(".slider-nav").animate({marginLeft: '-=133'});
    }           
}

当第二张幻灯片出现时,我如何让它移动。注意:将上面代码中的>1替换为>0会在页面加载后立即移动容器。

我不确定调用此函数的上下文。但我认为您需要以下代码:

function onBefore(currElement, nextElement, opts, isFoward) {
      if(opts.currSlide == opts.slideCount) {
         jQuery(".slider-nav").animate({marginLeft: '0'});
     } else { 
         jQuery(".slider-nav").animate({marginLeft: '-=133'});
     }
}
如果这不起作用,可能是因为您的第一张幻灯片是slideCount=0,而不是slideCount=1。如果是,将If测试更改为:

      if(opts.currSlide == (opts.slideCount - 1)) {
问候 尼尔