Button Submit Load Animation
by NunoMira
HTML
<article class="examples">
<div class="intro">
<h1>Arlina Design</h1>
<p>
A UI concept which merges loading indicators into the action that invoked them. Primarily intended for use with forms where
it gives users immediate feedback upon submit rather than leaving them wondering while the browser does its thing.
</p>
</div>
<section>
<h3>expand-left</h3>
<button class="arlina-button green expand-left"><span class="label">Submit</span> <span class="spinner"></span></button>
</section>
<section>
<h3>expand-right</h3>
<button class="arlina-button green expand-right"><span class="label">Submit</span> <span class="spinner"></span></button>
</section>
<section>
<h3>expand-up</h3>
<button class="arlina-button green expand-up"><span class="label">Submit</span> <span class="spinner"></span></button>
</section>
<section>
<h3>expand-down</h3>
<button class="arlina-button green expand-down"><span class="label">Submit</span> <span class="spinner"></span></button>
</section>
<section>
<h3>contract</h3>
<button class="arlina-button orange contract"><span class="label">Submit</span> <span class="spinner"></span></button>
</section>
<section>
<h3>contract-overlay</h3>
<button class="arlina-button orange contract-overlay" style="z-index: 10;"><span class="label">Submit</span> <span class="spinner"></span></button>
</section>
<section>
<h3>zoom-in</h3>
<button class="arlina-button orange zoom-in"><span class="label">Submit</span> <span class="spinner"></span></button>
</section>
<section>
<h3>zoom-out</h3>
<button class="arlina-button orange zoom-out"><span class="label">Submit</span> <span class="spinner"></span></button>
</section>
<section>
<h3>slide-left</h3>
<button class="arlina-button blue slide-left"><span class="label">Submit</span> <span class="spinner"></span></button>
</section>
<section>
<h3>slide-right</h3>
<button class="arlina-button blue slide-right"><span...
CSS
body {
background: #f5f5f5;
font-family: monospace;
font-size: 14px;
color: #333333;
}
.examples {
max-width: 670px;
margin: 2em auto;
padding: 4em;
background: #fff;
text-align: center
}
.examples .intro {
margin-bottom: 3em;
line-height: 1.4em;
font-size: 16px;
text-align: left;
}
.examples .intro h1 {
margin-top: 0;
font-size: 18px;
}
.examples .outro {
display: block;
text-align: right;
margin-top: 3em;
}
.examples section {
display: inline-block;
width: 24%;
min-width: 160px;
margin-bottom: 2em;
text-align: center;
vertical-align: top;
}
.examples section h3 {
color: #bbb;
font-weight: normal;
}
/*************************************
* BUTTON BASE
*/
.arlina-button {
position: relative;
background: none;
border: 0;
padding: 0.8em 1em;
font-size: 1.3em;
cursor: pointer;
outline: 0;
-webkit-appearance: none;
-webkit-font-smoothing: antialiased;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
.arlina-button[data-loading] {
cursor: default;
}
/* Green button */
.arlina-button.green {
background: #2aca76;
color: #fff;
border-radius: 2px;
border: 1px solid transparent;
}
.arlina-button.green:hover {
border-color: rgba( 0, 0, 0, 0.07 );
background-color: #2fe688;
}
.arlina-button.green[data-loading] {
border-color: rgba( 0, 0, 0, 0.07 );
background-color: #999;
}
/* Blue button */
.arlina-button.blue {
background: #53b5e6;
color: #fff;
border-radius: 2px;
border: 1px solid transparent;
}
.arlina-button.blue:hover {
border-color: rgba( 0, 0, 0, 0.07 );
background-color: #58c2f8;
}
.arlina-button.blue[data-loading] {
border-color: rgba( 0, 0, 0, 0.07 );
background-color: #999;
}
/* Orange button */
.arlina-button.orange {
background: #ea8557;
color: #fff;
border-radius: 2px;
border: 1px solid transparent;
}
.arlina-button.orange:hover {
border-color: rgba( 0, 0, 0, 0.07 );
background-color: #ffa96c;
}
.arlina-button.orange[data-loading]...
JavaScript
var buttons = document.querySelectorAll( '.arlina-button' );
Array.prototype.slice.call( buttons ).forEach( function( button ) {
var resetTimeout;
button.addEventListener( 'click', function() {
if( typeof button.getAttribute( 'data-loading' ) === 'string' ) {
button.removeAttribute( 'data-loading' );
}
else {
button.setAttribute( 'data-loading', '' );
}
clearTimeout( resetTimeout );
resetTimeout = setTimeout( function() {
button.removeAttribute( 'data-loading' );
}, 2000 );
}, false );
} );