swipejs的bug

Github:https://github.com/thebird/Swipe

以下bug的修复方式皆来自于网上。

现在最新的版本是2.0,bug如下:

1.触摸后不会自动播放

修复方式,

function stop() {  
  
    //delay = 0;  
    delay = options.auto > 0 ? options.auto : 0;  
    clearTimeout(interval );  
  
  }  

2.小于三个轮播元素,会多生成轮播元素

修复方式,

//Source codes: 
 if (browser.transitions && options.continuous && slides.length < 3) {
      element.appendChild(slides[0].cloneNode(true));
      element.appendChild(element.children[1].cloneNode(true));
      slides = element.children;
    }

//Modified codes:

  //special case if two slides
    if (browser.transitions && options.continuous && slides.length < 3) {
      //element.appendChild(slides[0].cloneNode(true));
      //element.appendChild(element.children[1].cloneNode(true));
      //slides = element.children;
    }

3.不同高度的轮播元素,矮的那位下面会有空白(为了布局稳定性,也不能说bug)

var height, heights = [];

function setup() {
    //前面不变... 
    container.style.visibility = 'visible'; //在这之后加 
    container.style.height = slides[index].offsetHeight + 'px'; //修复不同高度之间的切换 

}

function slide(to, slideSpeed) {
    //前面不变... 
    offloadFn(options.callback && options.callback(index, slides[index])); //在这之后加 
    setHeight(to);
}

function setHeight(index) { //修复不同高度之间的切换 
    if (-1 < index && index < slides.length) {
        height = slides[index].offsetHeight;
        container.style.height = height + 'px';
    }
}

以上代码来自于网上,只验证过前面两条。

原文地址:https://www.cnblogs.com/samwu/p/4080220.html