Open Bizarrus opened 6 years ago
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...
I wan't to tick manually the spinner.
For sample
let's run automatic. But i want to "move" the spinner programatically like