I am working in angular and in that, I am giving animations to text.
But here I want to set dynamic time for animation.
For example: Here I have created class .slide-in-top
in CSS
and set animation time to 1.3s
but I want to set it from function addAnimation()
like If I want to set it 2, 3 or 4 seconds
as I want.
And also I want to set that keyframes
values which is currently set transform: translateY(-40px)
here -40px
I have set static but I want to set it from addAnimation()
function as I want like -30px or-50px
etc.
addAnimation();
function addAnimation(){
$("#user_text").addClass('slide-in-top');
}
.slide-in-top {
-webkit-animation: slide-in-top 1.3s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;
animation: slide-in-top 1.3s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;
}
@-webkit-keyframes slide-in-top {
0% {
-webkit-transform: translateY(-40px);
transform: translateY(-40px);
opacity: 0;
}
100% {
-webkit-transform: translateY(0);
transform: translateY(0);
opacity: 1;
}
}
@keyframes slide-in-top {
0% {
-webkit-transform: translateY(-40px);
transform: translateY(-40px);
opacity: 0;
}
100% {
-webkit-transform: translateY(0);
transform: translateY(0);
opacity: 1;
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div style="margin-top: 20px; background:#0095ff;height:100px;padding:20px">
<p id="user_text">This is Animated text</p>
</div>