I have a animation like this in CSS
.outer {
margin: 50px;
}
.inner{
border: 1px solid black;
border-radius: 3px;
width: 100%;
height: 30px;
display: block;
background: linear-gradient(to right, hotpink 50%, transparent 0);
background-size: 200% 100%;
background-position: right;
animation: makeItfadeIn 3s 1s forwards;
}
@keyframes makeItfadeIn {
100% {
background-position: left;
}
}
<div class="outer">
<div class="inner">
</div>
<input type="range" value="20" min="0" max="100" class="inner"/>
</div>
I need to run a second animation, which I control from JavaScript. I want to animate the thumb
of <input type='range' />
. It needs to slide from left to right to a certain position. Setting the position of the thumb
is only possible from the JS side, thus the animation must be controlled in JS aswell.
This would be easy: But, the positioning must run completly in sync with the animation created in CSS. I can detect when the animation makeItfadeIn
starts on the CSS side, however, how to construct a function in Javascript, that mimics the animation: makeItfadeIn 3s 1s forwards;
: fast at the beginning, slowing down in the end, ... so that the thumb
of the range
starts at value=0
and moves in sync with the hotpink
bar to value=100
?