Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript Div 'Bounce' / 'Jiggle' [closed]

I noticed this effect within both Apple's me.com service (the login page, if your user/pass is wrong it does the effect I'm trying to replicate) as well as within WordPress' login.

Its basically a JavaScript implementation of the effect when you type in the wrong username and password on a Mac.

Does anyone know if something like that has been implemented open source or via a jQuery plugin?

like image 483
Ian Avatar asked Sep 04 '10 18:09

Ian


2 Answers

You could use the jQuery UI 'shake' effect.

Example: http://jsbin.com/alozu4

$('#theElement').effect('shake', 100);
like image 97
kennytm Avatar answered Oct 10 '22 09:10

kennytm


Even better: No Javascript, but only CSS3:

http://jsfiddle.net/fluidblue/dyc96/

@-webkit-keyframes wiggle
{
    0% {-webkit-transform: rotateZ(2deg);}
    50% {-webkit-transform: rotateZ(-2deg);}
    100% {-webkit-transform: rotateZ(2deg);}
}
@-moz-keyframes wiggle
{
    0% {-moz-transform: rotateZ(2deg);}
    50% {-moz-transform: rotateZ(-2deg);}
    100% {-moz-transform: rotateZ(2deg);}
}
@-o-keyframes wiggle
{
    0% {-o-transform: rotateZ(2deg);}
    50% {-o-transform: rotateZ(-2deg);}
    100% {-o-transform: rotateZ(2deg);}
}
@keyframes wiggle
{
    0% {transform: rotateZ(2deg);}
    50% {transform: rotateZ(-2deg);}
    100% {transform: rotateZ(2deg);}
}

.test {
    -webkit-animation: wiggle 0.2s ease infinite;
    -moz-animation: wiggle 0.2s ease infinite;
    -o-animation: wiggle 0.2s ease infinite;
    animation: wiggle 0.2s ease infinite;
}

Test it with

<div class="test" style="background-color: red;">Test</div>
like image 29
squarebrackets Avatar answered Oct 10 '22 08:10

squarebrackets