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

RefaelAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David S.Commented:
I haven't tried it, but you should be able to do that with a second rule (with a different class or something) and different animation settings.

.spin,
.spinBack {
	animation-name: spin;
	animation-duration: 8s;
	animation-iteration-count: infinite;
	animation-timing-function: linear;	
}
.spinBack {
	animation-direction: reverse;
	animation-iteration-count: 1;
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RefaelAuthor Commented:
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?
0
Slick812Commented:
greetings Refael, ,I do not understand why you use the Javascript for a mouseover, CSS has the mouseover as HOVER, U might try some css like this -

<!DOCTYPE HTML>
<html lang="en"><head><title>CSS Transitions</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />

<style>
body{background:#f9e8ff;margin:4px 1px;}

.tilt{
background-color:#baa;
width:120px;
height:100px;
margin:30px auto;
cursor:pointer;
position:relative;
top:0px;
text-align:center;
-webkit-border-radius:50%;-moz-border-radius:50%;-ms-border-radius:50%;-o-border-radius:50%;border-radius:50%;

-webkit-transition: all 2.1s linear;
-moz-transition: all 2.1s linear;
-o-transition: all 2.1s linear;
-ms-transition: all 2.1s linear;
transition: all 2.1s linear;
}

.tilt hr{margin-top:2em;}

.tilt:hover{
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
-ms-transform: rotate(90deg);
-o-transform: rotate(90deg);
transform: rotate(90deg);
 } 

</style>
</head><body><h3>CSS Transitions</h3>
<div class="tilt">ok<hr /></div>

</body></html>

Open in new window

you can use an Image instead of the <div> I have here for code development, but browsers that are not the most recent may need the extra -
         -moz-transition:

ask questions if this is not what you are trying to do.
0
RefaelAuthor Commented:
Thank you guys. Sorry I was away to respond.
0
David S.Commented:
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.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
CSS

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.