A metronome is any device that produces regular, metrical ticks (beats). [courtesy of wikipedia.org]
Simply put, when jQuery Metronome plugin is start
ed it ticks (triggers tick
event) on document level and keeps doing that periodically until stop
ped. It is an event-based wrapper of built-in setInterval
(well, setTimeout
to be precise) for jQuery.
Requires any version of jQuery
$.metronome.start(); // will tick once every second (default tempo)
$.metronome.start(10); // will tick 10 times a second
Each metronome tick then triggers "tick" event bindable on document like so:
$(document).bind('tick', function(){
... code which gets executed on each tick...
});
$.metronome.stop(); // will stop ticking
Default metronome tempo in ticks per second (Hz). Defaults to 1 Hz.
$.metronome.tempo= 10; // will set default tempo to 10 Hz
Name of the event periodically triggered on the document. Defaults to "tick".
$.metronome.event= "foo"; // will trigger "foo" event on each tick
Boolean value asserting that metronome is ticking.
$.metronome.ticking; // will return `true` in case of a ticking metronome
Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses. Copyright (c) 2010 Petr Vostrel