It seems like accomplishing this task without the use of JavaScript is unlikely. By implementing JavaScript, you can retrieve the style.webkitAnimationPlayState
of the specific element you want to modify. If the value is an empty string, then it indicates that it is currently set to its initial state, which is "running"
.
In the provided code snippet, clickDiv
refers to the div that triggers the action when clicked, while animationDiv
corresponds to the div whose webkit-animation-play-state
property is being altered:
clickDiv.addEventListener("click", function(){
if (animationDiv.style.webkitAnimationPlayState == "paused") {
animationDiv.style.webkitAnimationPlayState = "running";
}else if(animationDiv.style.webkitAnimationPlayState == "running" || animationDiv.style.webkitAnimationPlayState == ""){
animationDiv.style.webkitAnimationPlayState = "paused"; // toggling assumption
}
console.log(animationDiv.style.webkitAnimationPlayState);
});
Check out the demo here!