I have created an animation similar to described here: https://css-tricks.com/animating-the-content-property/
I can pause animation of movement but for some reason i cannot pause the animation of "content" with javascript (jQuery). I can set it default as paused but I cannot pause it after it starts running.
@-webkit-keyframes changeLetter {
0% {
content: "A";
}
50% {
color: white;
}
100% {
content: "B";
}
}
@keyframes changeLetter {
0% {
content: "A";
}
50% {
color: white;
}
100% {
content: "B";
}
}
@-webkit-keyframes move {
0% {
left: 50px;
}
100% {
left: 100px;
}
}
@keyframes move {
0% {
left: 50px;
}
100% {
left: 100px;
}
}
.element:after {
-webkit-animation: changeLetter 3s linear infinite alternate;
animation: changeLetter 3s linear infinite alternate;
content: "A";
}
.test{
position: relative;
left: 0px;
top: 0px;
width: 50px;
height: 50px;
background-color: red;
}
.test {
-webkit-animation: move 1s linear infinite alternate;
animation: move 1s linear infinite alternate;
}
.paused{
animation-play-state: paused !important;
-webkit-animation-play-state: paused !important;
}
$("#play").click(function() {
$('.animation').toggleClass('paused');
});
<div class="animation element"></div>
<div class="animation test"></div>
<button id="play" type="button">Pause/Play</button>
See the fiddle here: https://jsfiddle.net/eLt8zd33/1/
This is a very small code sample of my project.