| | |
| | | console.warn('未完整配置参数!'); |
| | | } |
| | | }; |
| | | |
| | | // 开启计时器不立即执行 |
| | | Timeout.prototype.startDelay = function(callback, time) { |
| | | // 先关闭计时器 |
| | | this.stop(); |
| | | // 配置执行函数 |
| | | if(typeof callback == 'function' && typeof time == 'number') { |
| | | this.callback = callback; |
| | | this.time = time; |
| | | |
| | | this.timer = setTimeout(callback, time); |
| | | }else { |
| | | console.warn('未完整配置参数!'); |
| | | } |
| | | }; |
| | | |
| | | // 开启计时器 |
| | | Timeout.prototype.open = function() { |
| | | var callback = this.callback; |
| | |
| | | this.start(callback, time, 'exe'); |
| | | }; |
| | | |
| | | |
| | | // 关闭计时器 |
| | | Timeout.prototype.stop = function() { |
| | | clearTimeout(this.timer); |