Trigger CSS Animations in JavaScript

后端 未结 8 1202
粉色の甜心
粉色の甜心 2020-11-28 14:14

I don\'t know how to use JQuery, so I need a method which could trigger an animation using JavaScript only.

I need to call/trigger CSS Animation when the user scrol

8条回答
  •  情书的邮戳
    2020-11-28 14:56

    I have a similar problem. The best answer didn’t work for me, but when I added the delay it worked. The following is my solution.

    CSS

    .circle_ani1,
    .circle_ani2 {
        animation-duration: 1s;
        animation-iteration-count: 1;
    }
    
    .circle_ani1 {
        animation-name: circle1;
    }
    
    .circle_ani2 {
        animation-name: circle2;
    }
    

    JS

    let temp_circle1 = $('.TimeCountdown_circle1').removeClass('circle_ani1');
    let temp_circle2 = $('.TimeCountdown_circle2').removeClass('circle_ani2');
    window.setTimeout(function() {
        temp_circle1.addClass('circle_ani1');
        temp_circle2.addClass('circle_ani2');
    }, 50);
    

提交回复
热议问题