new Tiny.ticker.CountDown()
Name | Type | Description |
---|---|---|
opts.duration |
number |
每次的时间间隔(ms) |
opts.times |
number |
共计次数 |
- Version:
- 1.1.7
Examples
var cd1 = new Tiny.ticker.CountDown({
duration: 5e3,
times: 3,
});
cd1.on('update', function (t) {
console.log('每五秒打印一次,共打印三次');
});
cd1.on('complete', function (t) {
console.log('Done');
});
cd1.start();
var cd2 = new Tiny.ticker.CountDown({
duration: 3e3,
});
cd2.on('update', function (t) {
console.log('每三秒打印一次,第' + cd2.count + '次');
});
cd2.start();
Members
-
countnumber
-
已计次数
- Default Value:
- 0
-
durationnumber
-
- Default Value:
- 1000ms
-
readonlyrunning
-
计时器是否正在运行
- Default Value:
- false
-
tickerTiny.ticker.Ticker
-
计时器使用的 Ticker 对象
-
timesnumber
-
- Default Value:
- Infinity
Methods
-
destroy()
-
销毁计时器
-
pause()
-
暂停计时,再次执行
start
会从上次暂停点继续 -
start()
-
开始计时,如果是被暂停的计时器,会从上次暂停点继续
-
停止计时
Events
-
complete
-
如果传入
times
,则会在计时结束后触发Name Type Description time
number -
调用
CountDown.pause()
后触发Example
var cd = new Tiny.ticker.CountDown(); cd.on('pause', function(){ console.log('paused'); }); cd.pause();
-
调用
CountDown.stop()
后触发Example
var cd = new Tiny.ticker.CountDown(); cd.on('stop', function(){ console.log('stop'); }); cd.stop();
-
update
-
每间隔
duration
触发一次Name Type Description time
number Example
var cd = new Tiny.ticker.CountDown(); cd.on('update', function(){ console.log('tick'); });