javascript - 如何让 Spin.js 旋转器在停止之前延迟?

标签 javascript spin.js

我有这样的代码

 var opts = {
    lines: 11, // The number of lines to draw
    length: 28, // The length of each line
    width: 25, // The line thickness
    radius: 35, // The radius of the inner circle
    corners: 1, // Corner roundness (0..1)
    rotate: 0, // The rotation offset
    direction: 1, // 1: clockwise, -1: counterclockwise
    color: '#000', // #rgb or #rrggbb or array of colors
    speed: 1.3, // Rounds per second
    trail: 61, // Afterglow percentage
    shadow: false, // Whether to render a shadow
    hwaccel: false, // Whether to use hardware acceleration
    className: 'spinner', // The CSS class to assign to the spinner
    zIndex: 2e9, // The z-index (defaults to 2000000000)
    top: 'auto', // Top position relative to parent in px
    left: 'auto' // Left position relative to parent in px
};

然后我这样调用微调器:

var target = document.getElementById('foo');
var spinner = new Spinner(opts).spin(target);
//do other stuff here
spinner.stop();

但我想在旋转器停止之前将其延迟一段时间。如何实现这一目标?如有任何帮助,我们将不胜感激。

最佳答案

var target = document.getElementById('foo');
var spinner = new Spinner(opts).spin(target);
//do other stuff here
// use setTimeout to add a delay to the stop
setTimeout(function(){
 spinner.stop();
}, 1000);

这将在 1000 毫秒后调用 spinner.stop()。您可以将其更改为您想要的任何内容。

关于javascript - 如何让 Spin.js 旋转器在停止之前延迟?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21234832/

相关文章:

javascript - spin.js 似乎不工作/出现

javascript - 递归解析对象数组并根据 id 过滤对象

javascript - 一页中有多个模式,其中一些模式是轮播

javascript - JQgrid虚拟滚动不加载新行

javascript - 扩展父级中的子属性会引发只读异常

javascript - 经纬度限制最大长度

javascript - spin.js 微调器未显示

javascript - spin.js 在长时间运行的任务期间不会显示,但在我单步执行调试器时会显示