繁体   English   中英

如何重置滑块1 onLeave?

[英]How do I reset the slider to slide 1 onLeave?

我正在使用fullPage.js的最新版本(2.1.8)来创建仪表板,通过更新window.location自动垂直和水平滑动。

jsfiddle

我面临的问题是,当我们回到第2部分时,滑块仍处于最终滑动位置,并且必须滑回到滑块1,然后才能向前滑过滑块。

我已经尝试按照问题#129的说明进行操作,该问题看起来适用于使用1.7.2版本的人:

  • 使scrollSlider函数公开
  • 更改对函数的调用名称
  • 申请onLeave事件代码:

     onLeave: function(index, nextIndex, direction){ //getting the section by the index var section = $('.section').eq((index - 1)); //if the section we are leaving has slides... if (section.find('.slides').length) { //moving to slide 0 $.fn.fullpage.scrollSlider(section, 0); } } 

但是,这对行为没有影响。

是否有人能够建议一种方法,以确保在使用最新版本的fullPage.js移动到下一部分时,滑块始终返回到默认幻灯片?

祝一切顺利,

AshBestos

我有同样的问题。 解决了函数scrollSlider()的副本。

将其命名为scrollDefault()函数并将此函数设置为public。

在我的jquery.fullPage.custom.js中

$.fn.fullpage.scrollDefault = function(section, slide){
  if(typeof slide != 'undefined'){
    var slides = section.find('.slides');
    var destiny =  slides.find('[data-anchor="'+slide+'"]');

    if(!destiny.length){
      destiny = slides.find('.slide').eq(slide);
    }

    if(destiny.length){
      landscapeScroll(slides, destiny);
    }
  }
};

setTimeout是隐藏滚动动画的快速而肮脏的解决方案。 因此,当您单击其他部分然后返回时,您会看到第一张幻灯片。

在我的$(文件).ready(function(){

onLeave: function(index, nextIndex, direction){
  setTimeout(function(){
    var section = $('.section').eq((index - 1));
    if (section.find('.slides').length) {
      $.fn.fullpage.scrollDefault(section, 0);
    }
  }, 500);
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM