Skip to content

Commit

Permalink
Prefix with d3, not d3_timer.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed Jan 7, 2016
1 parent 59a9ff5 commit 1eb907f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ In a vanilla environment, a `d3_timer` global is exported. [Try d3-timer in your

## API Reference

<a name="timer" href="#timer">#</a> d3_timer.<b>timer</b>(<i>callback</i>[, <i>delay</i>[, <i>time</i>]])
<a name="timer" href="#timer">#</a> d3.<b>timer</b>(<i>callback</i>[, <i>delay</i>[, <i>time</i>]])

Schedules a new timer, invoking the specified *callback* repeatedly until the timer is [stopped](#timer_stop). An optional numeric *delay* in milliseconds may be specified to invoke the given *callback* after a delay; if *delay* is not specified, it defaults to zero. The delay is relative to the specified *time* in milliseconds since UNIX epoch; if *time* is not specified, it defaults to [Date.now](https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/now).

The *callback* is passed two arguments when it is invoked: the elapsed time since the timer became active, and the current time. The latter is useful for precise scheduling of secondary timers. For example:

```js
var t = d3_timer.timer(function(elapsed, time) {
var t = d3.timer(function(elapsed, time) {
console.log(elapsed, time);
if (elapsed > 200) t.stop();
}, 150);
Expand All @@ -48,7 +48,7 @@ Note that the first *elapsed* is 6ms, since this is the elapsed time since the t
Use *delay* and *time* to specify relative and absolute moments in time when the *callback* should start being invoked. For example, a calendar notification for four hours before midnight on October 29, 2012 might be coded as:

```js
d3_timer.timer(callback, -4 * 1000 * 60 * 60, new Date(2012, 09, 29));
d3.timer(callback, -4 * 1000 * 60 * 60, new Date(2012, 09, 29));
```

If [timer](#timer) is called within the callback of another timer, the new timer callback (if eligible as determined by the specified *delay* and *time*) will be invoked immediately at the end of the current frame, rather than waiting until the next frame. Within a frame, timer callbacks are guaranteed to be invoked in the order they were scheduled (regardless of their start time).
Expand All @@ -65,7 +65,7 @@ Stops this timer, preventing subsequent callbacks. This method has no effect if

An opaque, unique identifier for this timer.

<a name="timerFlush" href="#timerFlush">#</a> d3_timer.<b>timerFlush</b>([<i>time</i>])
<a name="timerFlush" href="#timerFlush">#</a> d3.<b>timerFlush</b>([<i>time</i>])

Immediately execute (invoke once) any eligible timer callbacks. If *time* is specified, it represents the current time; if not specified, it defaults to Date.now. Specifying an explicit time helps ensure deterministic behavior.

Expand Down

0 comments on commit 1eb907f

Please sign in to comment.