Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Simple example of using spin.js (http://fgnass.github.io/spin.js) from Felix Gnass
<style>
.spinner {
position: fixed;
top: 50%;
left: 50%;
}
</style>
<script src="/javascripts/spin.js"></script>
<script>
var opts = {
lines: 11, // The number of lines to draw
length: 15, // The length of each line
width: 10, // The line thickness
radius: 30, // The radius of the inner circle
corners: 1, // Corner roundness (0..1)
rotate: 0, // The rotation offset
direction: 1, // 1: clockwise, -1: counterclockwise
color: '#000', // #rgb or #rrggbb
speed: 0.6, // Rounds per second
trail: 60, // Afterglow percentage
shadow: false, // Whether to render a shadow
hwaccel: false, // Whether to use hardware acceleration
className: 'spinner', // The CSS class to assign to the spinner
zIndex: 2e9, // The z-index (defaults to 2000000000)
top: 'auto', // Top position relative to parent in px
left: 'auto' // Left position relative to parent in px
};
var spinner = null;
var spinner_div = 0;
$(document).ready(function() {
spinner_div = $('#spinner').get(0);
$("#button1").on('click', function(e) {
e.preventDefault();
if(spinner == null) {
spinner = new Spinner(opts).spin(spinner_div);
} else {
spinner.spin(spinner_div);
}
});
$("#button2").on('click', function(e) {
e.preventDefault();
spinner.stop(spinner_div);
});
});
</script>
<p style='text-align: center;'>
<input type="button" id="button1" value="START">
&nbsp;
<input type="button" id="button2" value="STOP">
</p>
<div id='spinner' class='spinner'></div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment