Hi I am trying to convert my css animation to jquery animate.
I created a JSFiddle example: https://jsfiddle.net/x69chen/g86m7ecm/
You can see, I have commented out which I used to write
box1 {
animation: drop 1s ease forwards;
}
@keyframes drop {
from { opacity: 1 }
to { opacity: 1; top: calc(65% - 82px); }
}
Now I am trying to convert this to jquery because I am using vuejs component at frontend, and every time when the page reload the component, the animation runs again.
And I tried
var top = $(".box").parent().height() * 65% - 82;
$(".box").delay(2000).animate({
top: top
}, 1000);
It did not work well, because in jquery code, the box did not drop to the same location as it was in the css.
And I have set 2000 millisecond in the jquery delay function, but it seems it dropped much later than the delay time of 2s I set in CSS. Does anyone know why it is?
Thanks for any help!