【发布时间】:2013-09-22 13:10:16
【问题描述】:
我不知道如何在 setInterval 中的函数起作用时改变速度..
在代码中:
var timeout, count = 0, speed = 5000;
$('#stage').mousedown(function() {
timeout = setInterval(function() {
speed = parseInt(speed / 1.3); // HERE I want change speed
create(speed); // Some Function
}, speed); // This speed, I don't know how to change
});
$('#stage').mouseup(function() {
count = 0;
clearInterval(timeout);
});
这项工作但速度在函数之外是 const (5000)
非常感谢大家的帮助!
【问题讨论】:
-
改用
setTimeout循环。
标签: javascript performance time settimeout setinterval