Last active
August 29, 2015 14:02
-
-
Save jketcham/890d5639182b2e208831 to your computer and use it in GitHub Desktop.
Shake elements on hover
This file contains hidden or 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
| /** | |
| * Animate elements on hover | |
| * | |
| * Requires animate.css & JQuery | |
| */ | |
| $('.element').hover(function() { | |
| var element = $(this); | |
| element.addClass('animated shake'); | |
| }, function() { | |
| var element = $(this); | |
| element.removeClass('animated shake'); | |
| } | |
| ); |
This file contains hidden or 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
| .animated { | |
| -webkit-animation-duration: 1s; | |
| animation-duration: 1s; | |
| -webkit-animation-delay: .5s; | |
| animation-delay: .5s; | |
| -webkit-animation-fill-mode: both; | |
| animation-fill-mode: both; | |
| } | |
| @-webkit-keyframes shake { | |
| 0%, 100% { | |
| -webkit-transform: translateX(0); | |
| transform: translateX(0); | |
| } | |
| 10%, 30%, 50%, 70%, 90% { | |
| -webkit-transform: translateX(-10px); | |
| transform: translateX(-10px); | |
| } | |
| 20%, 40%, 60%, 80% { | |
| -webkit-transform: translateX(10px); | |
| transform: translateX(10px); | |
| } | |
| } | |
| @keyframes shake { | |
| 0%, 100% { | |
| -webkit-transform: translateX(0); | |
| -ms-transform: translateX(0); | |
| transform: translateX(0); | |
| } | |
| 10%, 30%, 50%, 70%, 90% { | |
| -webkit-transform: translateX(-10px); | |
| -ms-transform: translateX(-10px); | |
| transform: translateX(-10px); | |
| } | |
| 20%, 40%, 60%, 80% { | |
| -webkit-transform: translateX(10px); | |
| -ms-transform: translateX(10px); | |
| transform: translateX(10px); | |
| } | |
| } | |
| .shake { | |
| -webkit-animation-name: shake; | |
| animation-name: shake; | |
| @include animate-delay(0s); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment