I'm working on a webapp that uses CSS3 animations for some nice effects, but I can't figure out to activate them with an onclick
event.
this is the CSS3 Animation: (The name of the DIV this is added to is #smspopup
)
#smspopup {
-webkit-animation: move-sms 1.5s 1;
-webkit-animation-fill-mode: forwards;
}
And this is my Javascript where I just can't figure out what I need to get it going
function cancel_sms()
{
halte.style.opacity = 1;
document.getElementById('smspopup').style.visibility = 'hidden';
document.getElementById('up').style.visibility = 'visible';
}
And another thing I want to do is delay the functions 1.5 seconds until the animation is finished. Anyone any idea?
I'm working on a webapp that uses CSS3 animations for some nice effects, but I can't figure out to activate them with an onclick
event.
this is the CSS3 Animation: (The name of the DIV this is added to is #smspopup
)
#smspopup {
-webkit-animation: move-sms 1.5s 1;
-webkit-animation-fill-mode: forwards;
}
And this is my Javascript where I just can't figure out what I need to get it going
function cancel_sms()
{
halte.style.opacity = 1;
document.getElementById('smspopup').style.visibility = 'hidden';
document.getElementById('up').style.visibility = 'visible';
}
And another thing I want to do is delay the functions 1.5 seconds until the animation is finished. Anyone any idea?
Share Improve this question edited Jul 23, 2021 at 9:21 Brian Tompsett - 汤莱恩 5,89372 gold badges61 silver badges133 bronze badges asked Aug 24, 2012 at 14:31 IanBautersIanBauters 1531 gold badge2 silver badges8 bronze badges 1- This question might help. – Barlas Apaydin Commented Aug 24, 2012 at 14:34
1 Answer
Reset to default 3Starting the animation
Start by using a class instead of an ID. Change the CSS to this:
.smspopup {
-webkit-animation: move-sms 1.5s 1;
-webkit-animation-fill-mode: forwards;
}
And add class=smspopup
to the smspopup
element.
Next, inside the handler (cancel_sms
?), just add the class to the element to begin the animation:
document.getElementById('smspopup').className = 'smspopup';
Animation end callback
For the second question (targeting the end of the animation), there are two options:
Attach a callback to the transitionEnd event. The only problem with this is that you need to listen to vendor-specific events:
myDiv.addEventListener('webkitAnimationEnd', callback);
Use a regular timeout. The problem with this is that the timing won't be perfect (but maybe close enough).
setTimeout(callback, 1500);
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745302089a4621495.html
评论列表(0条)