我有这样的代码
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/