swiper 循环切换_swiper 循环滑动问题

需要在源码中加两行代码进行判断,分别是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);

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值