Link to home
Start Free TrialLog in
Avatar of Refael
RefaelFlag for United States of America

asked on

CSS3 spin keyframes

Hello Experts,

Yet to learn CSS transform  :-)

I have a circle image which I am spinning (360deg) on mouse-over.
When the user mouse-out I would like the circle to slowly and gradually roll back from the point it currently is and stop. Is it possible with CSS?


@keyframes spin {
 0% {
 transform:rotate(0deg); 
 
 }
 100% {
 transform:rotate(360deg);
 
 }
}

.spin {
    animation-name: spin;
    animation-duration: 8s;
    animation-iteration-count: infinite;
    animation-timing-function: linear;	
}

Open in new window


$(document).ready(function() {
	
	$(".playbtn").hover(function() {
		$(this).addClass("spin");		
	}, function() {
		$(this).removeClass("spin");	
	});
    
});

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of David S.
David S.
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Refael

ASKER

Kravimir thank you.
It does not look so good :-(
Maybe only to make it stop slowly and not immediately when the user mouse-out?
So not backwards just simply to stop slowly?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Refael

ASKER

Thank you guys. Sorry I was away to respond.
Two weeks is a little slow but many people have taken longer to respond.

To make an animation slow to a stop you could try using "ease-out" as the timing instead of "linear" in addition to setting the iteration-count to 1. You might want to increase the duration for that as well.

Otherwise, JavaScript using requestAnimationFrame() would be needed.