not really known
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

58 lines
1.1 KiB

// Timer object
enyo.kind({
name: "Timer",
kind: enyo.Component,
minInterval: 50,
published: {
baseInterval: 100, paused: false
},
events: {
onTriggered: ""
},
// Constructor, start the timer
create: function() {
this.inherited(arguments);
this.start();
},
// Destroy the timer
destroy: function() {
this.stop();
this.inherited(arguments);
},
// Start the timer
start: function() {
this.job = window.setInterval(enyo.bind(this, "timer"), this.baseInterval);
},
// Stop the timer
stop: function() {
window.clearInterval(this.job);
},
// Pause timer
pause: function() {
this.paused = true;
},
// Resume the timer
resume: function() {
this.paused = false;
},
// Periodic event raised
timer: function() {
if (!this.paused)
this.doTriggered({time: new Date().getTime()});
},
// Interval changed event
baseIntervalChanged: function(inOldValue) {
this.baseInterval = Math.max(this.minInterval, this.baseInterval);
this.stop();
this.start();
}
});