Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
李勇
/
McuClient
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
李勇
2017-02-24 11:59:35 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
b46a5279378dff2a39d2e66665d77765fccb5de9
b46a5279
1 parent
27c5accd
1.增加计时器
显示空白字符变更
内嵌
并排对比
正在显示
1 个修改的文件
包含
64 行增加
和
0 行删除
src/TimerCounter.js
src/TimerCounter.js
0 → 100644
查看文件 @
b46a527
// //////////////////////////////////////////////////////////////////////////////
// 计时器
// //////////////////////////////////////////////////////////////////////////////
//import ApeConsts from './ApeConsts';
//import Loger from 'Loger';
//import MessageTypes from 'MessageTypes';
//import GlobalConfig from 'GlobalConfig';
//import EngineUtils from 'EngineUtils';
//let loger = Loger.getLoger('MediaModule');
let
counter
=
0
;
let
callBackDelay
=
1
;
let
callBackFun
;
let
isStart
=
false
;
class
TimerCounter
{
constructor
()
{
this
.
timer
=
0
;
this
.
delay
=
1000
;
}
addTimerCallBack
(
_callBackFun
,
_callBackDelay
){
callBackFun
=
_callBackFun
;
callBackDelay
=
_callBackDelay
;
}
//开计时
startTimer
(
_position
=
0
)
{
if
(
isStart
)
return
;
isStart
=
true
;
if
(
_position
&&
parseInt
(
_position
)
>
0
){
counter
=
_position
;
}
else
{
counter
=
0
;
}
console
.
log
(
"startTimer"
,
counter
);
this
.
timerClear
();
this
.
timerStart
();
}
//停止
stopTimer
(){
console
.
log
(
"stopTimer"
,
counter
);
isStart
=
false
;
this
.
timerClear
();
}
//计数
updateCounter
(){
counter
++
;
//this.counter++;
//console.log("TimerCounter",counter);
if
(
callBackFun
!=
null
&&
counter
%
callBackDelay
==
0
){
callBackFun
();
}
}
timerStart
(){
this
.
timer
=
setInterval
(
this
.
updateCounter
,
this
.
delay
);
}
timerClear
(){
clearInterval
(
this
.
timer
);
}
}
export
default
TimerCounter
;
...
...
请
注册
或
登录
后发表评论