Javascript 如何让Spin.js微调器在停止前延迟?
我有这样的代码Javascript 如何让Spin.js微调器在停止前延迟?,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) rotat
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);
那你就给我打电话
setTimeout(function(){spinner.stop()},5000);
在给定的毫秒数之后,函数将执行并停止计时器
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()
。您可以随意更改。延迟到底是什么意思?你想让它至少旋转x秒吗?@Liath是的,这就是我想让它改变想法的原因!抱歉,我无法+1您我已使用配额:(