clui
clui copied to clipboard
Spinner with manual ticking
I wan't to tick manually the spinner.
For sample
var countdown = new CLI.Spinner('Running... ', ['⣾','⣽','⣻','⢿','⡿','⣟','⣯','⣷']);
countdown.start();
let's run automatic. But i want to "move" the spinner programatically like
var countdown = new CLI.Spinner('Running... ', ['⣾','⣽','⣻','⢿','⡿','⣟','⣯','⣷']);
setInterval(function() {
countdown.tick();
}, 1000); // each second, the spinner moves...
Well the symbols are in the order they are to be animated, so why not just output and replace each symbol every tick?
So something like
var spinnerSymbols = ['⣾','⣽','⣻','⢿','⡿','⣟','⣯','⣷'];
var i = 0;
setInterval(function() {
process.stdout.clearLine(); // clear line
process.stdout.cursorTo(0); // move to the start of the line
process.stdout.write(spinnerSymbols[i]); // write the symbol
// Increase the counter until it reaches the end of the array
if(i >= (spinnerSymbols.length - 1)) {
i = 0;
} else {
i++;
}
}, 1000); // each second, the spinner moves...