Last active
December 29, 2015 11:59
-
-
Save webapprentice/7667149 to your computer and use it in GitHub Desktop.
Simple example of using spin.js (http://fgnass.github.io/spin.js) from Felix Gnass
This file contains 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
<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"> | |
| |
<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