Created
October 13, 2013 16:51
-
-
Save astericky/6964428 to your computer and use it in GitHub Desktop.
Animation Grid Auto Rotate
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
$grid: ( | |
"x ", | |
" x ", | |
" x ", | |
" x ", | |
" x ", | |
" x ", | |
" x ", | |
" x ", | |
" x ", | |
" x ", | |
" x ", | |
" x ", | |
" x ", | |
" x", | |
" x ", | |
" x ", | |
" x ", | |
" x ", | |
" x ", | |
" x " | |
); | |
$grid-width: str-length(nth($grid, 1)); | |
$column-width: 100% / $grid-width; | |
$row-height: 100% / length($grid); | |
@function angle($old, $new) { | |
$steepness: (($new - $old) / $grid-width) * 100; | |
$angle: 180 - (0.9 * $steepness); | |
@return $angle; | |
} | |
@-webkit-keyframes fly { | |
$i: 1; | |
$prev-position: 0; | |
@each $row in $grid { | |
$position: str-index(nth($row, 1), 'x'); | |
$angle: angle($prev-position, $position); | |
$prev-position: $position; | |
#{$row-height * $i} { | |
-webkit-transform: translate($row-height * $i, $column-width * $position) rotate(#{$angle}deg); | |
} | |
$i: $i + 1; | |
} | |
} | |
#rocket { | |
position: absolute; | |
margin: -87.5px 0 0 -50px; | |
-webkit-animation-name: fly; | |
-webkit-animation-duration: 5s; | |
-webkit-animation-timing-function: linear; | |
-webkit-animation-fill-mode: forwards; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment