Skip to content

Instantly share code, notes, and snippets.

@srajagop
Created June 17, 2015 12:54
Show Gist options
  • Save srajagop/4c6d1fe0d887c8de4564 to your computer and use it in GitHub Desktop.
Save srajagop/4c6d1fe0d887c8de4564 to your computer and use it in GitHub Desktop.
animation submit button
<div class="container">
<button id="button"></button>
</div>
$(function() {
$( "#button" ).click(function() {
$( "#button" ).addClass( "onclic", 250, validate);
});
function validate() {
setTimeout(function() {
$( "#button" ).removeClass( "onclic" );
$( "#button" ).addClass( "validate", 450, callback );
}, 2250 );
}
function callback() {
setTimeout(function() {
$( "#button" ).removeClass( "validate" );
}, 1250 );
}
});
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
$green: #1ECD97;
$gray: #bbbbbb;
* {
font-family: 'Roboto', sans-serif;
}
.container {
position: absolute;
top:50%;
left:50%;
margin-left: -65px;
margin-top: -20px;
width: 130px;
height: 40px;
text-align: center;
}
button {
outline:none;
height: 40px;
text-align: center;
width: 130px;
border-radius:40px;
background: #fff;
border: 2px solid $green;
color:$green;
letter-spacing:1px;
text-shadow:0;
font:{
size:12px;
weight:bold;
}
cursor: pointer;
transition: all 0.25s ease;
&:hover {
color:white;
background: $green;
}
&:active {
//letter-spacing: 2px;
letter-spacing: 2px ;
}
&:after {
content:"SUBMIT";
}
}
.onclic {
width: 40px;
border-color:$gray;
border-width:3px;
font-size:0;
border-left-color:$green;
animation: rotating 2s linear infinite;
&:after {
content:"";
}
&:hover {
color:$green;
background: white;
}
}
.validate {
font-size:13px;
color: white;
background: $green;
&:after {
font-family:'FontAwesome';
content:"\f00c";
}
}
@keyframes rotating {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
<link href="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css" rel="stylesheet" />
<link href="http://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment