我想使用 Spin.js 来显示微调器。我可以做到,但我无法阻止。
我的代码:
function startSpin() {
var target = document.getElementById('demarrer');
new Spinner().spin(target);
setTimeout("dummyFunc()", 4000);
}
function dummyFunc() {
console.log("bouh");
}
我必须调用什么才能停止旋转器?
我已经尝试过:
- Spinner().stop(目标);
- Spinner().spin(target).stop();
- Spinner().stop();
没有结果...='(
谢谢!
最佳答案
首先,我必须说,我从未使用过 Spinner,也不知道它是如何工作的,但我相当确定问题在于,您只是在创建 Spinner 实例后将其丢弃。而不是
new Spinner().spin(target);
尝试写
var spinner = new Spinner().spin(target);
然后,要停止旋转器,请写入:
spinner.stop();
完整代码:
function startSpin() {
var target = document.getElementById('demarrer');
var spinner = new Spinner().spin(target);
// Run a function after 4 seconds.
setTimeout(function() {
console.log("bouh");
spinner.stop(); // Stop the spinner
}, 4000);
}
关于javascript - 如何在 spin.js 中隐藏微调器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12408019/