Adding an inertia effect to a rotation transform
Created
April 21, 2015 23:02
-
-
Save vdel26/2c35afe98cb545f4414d to your computer and use it in GitHub Desktop.
Intertial rotating animation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="box"> | |
<div class="star"></div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.box { | |
margin: 0 auto; | |
position: relative; | |
top: 200px; | |
width: 100px; | |
height: 100px; | |
transform: rotateZ(0); | |
transition: all 900ms ease-out; | |
cursor: pointer; | |
} | |
.box:hover { | |
transform: rotateZ(-60deg); | |
} | |
.star { | |
position: relative; | |
width: 100px; | |
height: 100px; | |
background: url(https://cldup.com/HeqDhxgwV2.png) center no-repeat; | |
background-size: 100px 100px; | |
animation-name: spin; | |
animation-duration: 2000ms; | |
animation-timing-function: linear; | |
animation-iteration-count: infinite; | |
animation-play-state: paused; | |
} | |
.box:hover .star { | |
animation-play-state: running; | |
} | |
@keyframes spin { | |
0% { transform: rotateZ(0) } | |
100% { transform: rotateZ(360deg) } | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment