+ 2
Hello, any solution so that the animation speed is not altered.
I have tried to solve the problem but I do not understand what happens, does anyone know any solution? https://code.sololearn.com/WKkuvu3fvMSh/?ref=app
2 ответов
+ 3
<!--Cosider modifying script-->
<script>
var pos = 0;
animation1();
function animation1() {
if (pos >= 30) {animation2();}
else {
pos += 0.1;
p.style.left = pos + "%";
requestAnimationFrame(animation1);;
};
x.innerHTML = pos;
};
function animation2() {
if (pos <= 0) {animation1();}
else {
pos -= 0.1;
p.style.left = pos + "%";
requestAnimationFrame(animation2);
};
x.innerHTML = pos;
};
</script>
+ 3
thanks for the help, the truth is that I imagined the solution more or less like this but I didn't quite know how to write it. :)