javascript - Jump problem in carousel chart
怪我咯
怪我咯 2017-05-19 10:34:28
0
1
440

There are four carousel items in total, and three can appear on the screen. I placed two copies side by side in the html to implement wireless carousel. However, when the position is at the starting point, clicking the forward button will cause a jump process. But when I execute it step by step in Chrome debugging, it doesn't jump. What's going on? The js code is as follows

pre.onclick=function(){              //pre为前移按钮
        if(index==0){                 //index==0对应屏幕出现前三个项
            index=4;
            oUl.style.transition='none';           //将css中的transition消除
            oUl.style.transform='translateX('+(-425)*index+'px)';   //移动到index==4
        }
        index--;
        clearInterval(timer);        //清除定时器
        oUl.style.transition='all 1s';    //设置过渡
        oUl.style.transform='translateX('+(-425)*index+'px)';   //移动到index==3
        timer=setInterval(move,2000);     //开启定时器
    }
怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(1)
巴扎黑

Isn’t the initial value 0? After you click, it will jump to 4

oUl.style.transform='translateX('+(-425)*index+'px)';
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template