需要在源码中加两行代码进行判断,分别是move移动时的禁止移动与end结束时的禁止跳转;
(代码不能加粗 具体看有注释的那行)
1.查swipe源码里的move函数,其中有一个判断:
if (options.continuous) {
if(delta.x > 0 && index==0){return false}//加上这行
translate(circle(index-1), delta.x + slidePos[circle(index-1)], 0);
translate(index, delta.x + slidePos[index], 0);
translate(circle(index+1), delta.x + slidePos[circle(index+1)], 0);
} else {
2.查swipe源码里的end函数,其中有一个判断:
if (direction) {
if (options.continuous) {
move(circle(index-1), -width, 0);
move(circle(index+2), width, 0);
} else {
move(index-1, -width, 0);
}
move(index, slidePos[index]-width, speed);
move(circle(index+1), slidePos[circle(index+1)]-width, speed);
index = circle(index+1);
} else if(index!=0){ //源码中是else 此处需要加判断index!=0
if (options.continuous) {
move(circle(index+1), width, 0);
move(circle(index-2), -width, 0);
} else {
move(index+1, width, 0);
}
move(index, slidePos[index]+width, speed);
move(circle(index-1), slidePos[circle(index-1)]+width, speed);
index = circle(index-1);
}