简体   繁体   中英

Ladda spin animation keeps spinning for one second after stop()

I'm using ladda spinner like this:

var l = Ladda.create(document.getElementById('ladda-test'));
l.start();
l.stop();
console.log('ladda is stoped');

My problem is that after l.stop() is executed, the animation does not instantly stop: the spin animation only stops after one second.

You can use a timeout function to wait one second - then execute your code.

The setTimeout() method will wait the specified number of milliseconds, and then execute the specified function.

The first parameter of setTimeout() should be a function.

The second parameter indicates how many milliseconds, from now, you want to execute the first parameter.

For example:

var l = Ladda.create(document.getElementById('ladda-test'));
l.start();
setTimeout(function() {
    l.stop();
    console.log('ladda is stoped');
}, 2000); // This unit equates to two seconds

You can learn more about timing events here: http://www.w3schools.com/js/js_timing.asp

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM