pergola.Timer is not subclassed to pergola.Class.

This class gives full and precise control over timing processes of all kinds, and allows concurrent processes and multiple timing controllers for a same process/animation. Its instances are self-managing (no global or local indexing). If an instance is not specifically destroyed it's reusable, and its properties (including the callback) may be overridden for subsequent uses, or dynamically for the current process by another controller. For extensive information about this class and examples read the SVG magazine Timer Class article.



The properties of object are inherited by this. Instantiation/initialization can look like this:

 myObject.timer = pergola.Timer()
    handle : object,
    callback : function,
    delay : ms,
    frequence : ms,
    destroy : "variable/property"
where callback is required. If handle is specified callback will be invoked as a method of handle (with this as parameter); if not specified, handle is this, and therefore callback will be invoked as a method of this. The property handle can reference any object (including window), not necessarily the object in the context of which Timer was instantiated (key to multiple controllers).

If delay and/or frequence are specified window.setInterval() and window.setTimeout() will be used accordingly.

If destroy is specified the instance will be destroyed and cannot be reused. In most cases destruction is not sought, note however that the class doesn't follow a classic JavaScript OOD model and its methods are not prototype methods; therefore each instance has its own copy of each method, and while this is not important in small or short-lived applications, it may cause so-called memory leaks with large and resident applications.

object can define any other properties relating for example to iterations, date, abortion, etc., all available in the callback function.

The method dynamically assigns the properties timeout and/or interval.


This method is invoked by initialize if frequence was specified. This method must not be invoked explicitly.


Invoke this method to release the timer. Sets the timeout and/or interval properties (set in initialize()) to null, to the exclusion of any other property, and destroys the instance if destroy was specified.