new Bling.ticker.CountDown(opts)
bling/ticker/CountDown.js, line 38
一个较高精度、较高性能的计时器
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts |
object |
|
Examples
const cd1 = new Bling.ticker.CountDown({
duration: 5e3,
times: 3,
});
cd1.on('update', function (t) {
console.log('每五秒打印一次,共打印三次');
});
cd1.on('complete', function (t) {
console.log('Done');
});
cd1.start();
const cd2 = new Bling.ticker.CountDown({
duration: 3e3,
});
cd2.on('update', function (t) {
console.log('每三秒打印一次,第' + cd2.count + '次');
});
cd2.start();
Extends
- EventEmitter
Members
-
readonlyrunning
-
计时器是否正在运行
- Default Value:
- false
Methods
-
destroy()
bling/ticker/CountDown.js, line 155 -
销毁计时器
-
pause()
bling/ticker/CountDown.js, line 140 -
暂停计时,再次执行
start
会从上次暂停点继续 -
start()
bling/ticker/CountDown.js, line 110 -
开始计时,如果是被暂停的计时器,会从上次暂停点继续
-
stop()
bling/ticker/CountDown.js, line 147 -
停止计时
Events
-
complete
bling/ticker/CountDown.js, line 62 -
如果传入
times
,则会在计时结束后触发Name Type Description time
number -
pause
bling/ticker/CountDown.js, line 68 -
调用
CountDown.pause()
后触发Example
const cd = new Bling.ticker.CountDown(); cd.on('pause', function(){ console.log('paused'); }); cd.pause();
-
stop
bling/ticker/CountDown.js, line 80 -
调用
CountDown.stop()
后触发Example
const cd = new Bling.ticker.CountDown(); cd.on('stop', function(){ console.log('stop'); }); cd.stop();
-
update
bling/ticker/CountDown.js, line 50 -
每间隔
duration
触发一次Name Type Description time
number Example
const cd = new Bling.ticker.CountDown(); cd.on('update', function(){ console.log('tick'); });