[JS] Animation Event

ChenΒ·2024λ…„ 6μ›” 12일
0

Javascript

λͺ©λ‘ 보기
14/22
post-thumbnail

CSS Animation 정리글

@keyframes ball-ani {
    from {
        transform: translate(0, 0);
    }
    to {
        transform: translate(200px, 200px);
    }
}

animationstart

ballElm.addEventListener('click', function () {
    ballElm.style.animation = `ball-ani 1s 3 alternate forwards`;
});

animationend

ballElm.addEventListener('animationend', function () {
    ballElm.classList.add('end');
});

animationiteration

μ• λ‹ˆλ©”μ΄μ…˜μ΄ λ°˜λ³΅λ˜λŠ” μ‹œμ μ„ μž‘μ•„λ‚Ό μˆ˜λ„ 있음
재수 μ‚Όμˆ˜ λŠλ‚Œ. ν˜„μ—­ λ•ŒλŠ” μ•ˆμž‘νžˆκ³  반볡 count만 함

// λΆ„λͺ… 3번 반볡인데 2번 μ°νžˆλŠ” μ΄μœ μž„

animation: ball-ani 1s 3 alternate forwards;
ballElm.addEventListener('animationiteration', function () {
    console.log('반볡!');
});

profile
ν˜„μ‹€μ μΈ λͺ½μƒκ°€

0개의 λŒ“κΈ€