당신은 serval 방식으로 할 수 있습니다.
한 가지 방법은 요소에 애니메이션 클래스를 추가하기 전에 요소의 재 흐름을 트리거하는 것입니다. 예를 들어
element.offsetWidth = element.offsetWidth;
(바닐라 JS)
if (element2.classList.contains('show')) {
element2.classList.remove("show");
//restarting css3 keyframe animation
**element2.offsetWidth = element2.offsetWidth;**
element2.classList.add("hide");
}else{
element2.classList.remove("hide");
//restarting css3 keyframe animation
**element2.offsetWidth = element2.offsetWidth;**
element2.classList.add("show");
}
의 jQuery 버전 : 그것은 여기
if(settingPopup.hasClass('show')){
settingPopup.removeClass('show');
//line below is a fix to restart css3 keyframe animation
//settingPopup.outerWidth(settingPopup.outerWidth)
settingPopup.outerWidth(settingPopup.outerWidth).addClass('hide');
}else{
settingPopup.removeClass('hide');
//line below is a fix to restart css3 keyframe animation
//settingPopup.outerWidth(settingPopup.outerWidth)
settingPopup.outerWidth(settingPopup.outerWidth).addClass('show');
}
있고 작동 바이올린 : https://jsfiddle.net/zpawpvke/2/
기준 : https://css-tricks.com/restart-css-animation/
나는 대답을 찾을 수 없으므로 나는 그것을 myslef로 만든다 – born2fr4g
http://stackoverflow.com/questions/35200605/refire-css-animation-with-javascript-after-a-previous-one-is-complete/35203145 # 35203145 – Harry
다른 접근 방식입니다. 내 것은 짧고 쉬우 며 조금 다른 질문이다. (클래스 추가시) – born2fr4g