Spin.js - test for issue #48
https://github.com/fgnass/spin.js/issues/48
HTML
<script src="http://fgnass.github.com/spin.js/spin.js"></script>
<button onclick="remove1()">Remove</button>
<button onclick="add2()">Add</button>
<div id="spin">click "Add" to show spiner</div>
CSS
div{
font-family:arial;
}
JavaScript
var div = document.getElementById('spin');
var spinner = new Spinner().spin(div).stop(),
msg =$('#spin'),
count=5e8;
// txt='';
function remove1() {
spinner.stop();
// msg.text('');
div.parentNode.removeChild(div);
}
function add2() {
sequence(dummyCounter);
}
function dummyCounter(){
for(var i=0;i<5;i++){
for(var j=0;j<count;j++){}
msg.append('count= '+ i+'<br \>');
}
msg.append('finished~'+i+'<br \>');
}
function sequence(myCallback){
msg.html('start counting~<br \>');
document.body.appendChild(div);
spinner.spin(div);
myCallback();
}