Licence: Apache License, Version 2.0
Demo: http://dev.maxschuster.eu/jQuery.timer/
jQuery wrapper for setInterval() with events
var $timer = $({}).timer({
'delay': 1000,
'repeatCount': 5
}).on('tick.timer complete.timer stop.timer start.timer reset.timer destroy.timer', function(e, d) {
console.log(e.type, d);
}).timer('start');
Initializes the plugin on a jQuery object
$({}).timer(options);
Name | Type | Default | Comment |
---|---|---|---|
options | Object | {} | Plugin options to override predefined settings. (See Settings) |
jQuery Object To provide chainability.
Starts the timer
$({}).timer('start');
jQuery Object To provide chainability.
Stops the timer
$({}).timer('stop', triggerEvent);
Name | Type | Default | Comment |
---|---|---|---|
triggerEvent | Boolean | true | Trigger the stop.timer event? |
jQuery Object To provide chainability.
Stops the timer and resets its repeatCount.
$({}).timer('reset');
jQuery Object To provide chainability.
Removes the timer from the current jQuery object
$({}).timer('destroy');
jQuery Object To provide chainability.
$({}).timer({
'repeatCount': 5
}).on('tick.timer, function(event, data) {
console.log(event, data);
});
Name | Type | Comment |
---|---|---|
event | Object | jQuery event |
data | Object | Timer information (Boolean running, Integer repeatCount, Integer delay, Integer currentCount) |
Dispatched whenever a Timer object reaches an interval specified according to the delay option.
Dispatched whenever it has completed the number of requests set by repeatCount option.
Dispatched whenever the timer has been stoped.
Dispatched whenever the timer has been started.
Dispatched whenever the timer has been reseted.
Dispatched whenever the timer has been destroyed.
The delay between tick.timer events in milliseconds.
Type: Integer
Default: 1000
The number of times the timer has to tick till its complete
Type: Integer
Default: 1
Start the timer after initializing
Type: Boolean
Default: false