CSS carousel switching animation - Stack Overflow
習慣沉默
習慣沉默 2017-06-12 09:33:00
0
1
892

As shown in the picture

When an animation written in JS is set with an excessive effect, such a situation will occur. How can JS change this situation?

function moveSlide() {
  var slides = $('.slide');
  
  // for (var i = 0; i < slides.length; i++) {
    slides.forEach(function(item) {
      var leftValue = parseInt(item.style.left);

      if (leftValue == -100) {
        leftValue = 100;
        item.style.left = leftValue + '%';
      }else if(leftValue == 100 || leftValue == 0){
        leftValue -= 100;
        item.style.left = leftValue + '%';
      }
    }, this);
習慣沉默
習慣沉默

reply all(1)
学习ing

1.leftValue=0 >> leftValue -=100 >> leftValue=-100
2.leftValue=-100 >> ; leftValue -=100 >> leftValue=-100
Only two values ​​of your leftValue are changing. Your judgment is wrong. Since you are using transition animation, it is recommended to use animate();

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template