Home Doc API Examples GitHub

Example Timing Callback (page-local)

setPointCallback and setIntervalCallback are simple tools inspired by setTimeout and setInterval. setPointCallback triggers a callback when the timing object passes by a specific point on the timeline. setIntervalCallback is associated with periodic points along the timeline.

Demo

Timing Object

SetPointCallback

  • SetPointCallbackOnce generates a callback the first time position 4 is reached.
  • SetPointCallbackRepeat generates a callback every time position 6 is reached.

SetIntervalCallback

  • SetIntervalCallback is set up with length 6 and offset 2, generating periodical callbacks at ...,2,8,14,20,...

Callback Log

JavaScript

TIMINGSRC.setPointCallback(to, function () {
	append("point callback (once) at position " + to.query().position.toFixed(2));
}, 4);

TIMINGSRC.setPointCallback(to, function () {
    append("point callback (repeated) at position " + to.query().position.toFixed(2));
}, 6, {repeat:true});

TIMINGSRC.setIntervalCallback(to, function () {
    append("interval callback at position " + to.query().position.toFixed(2));
}, 6, {offset:2});