JS API

autoUpdate([interval]), cancelAutoUpdate()

Start or stop periodic re-rendering from JavaScript, the counterpart of the auto:update attribute.

Syntax

  • doodle.autoUpdate([interval])
  • doodle.cancelAutoUpdate()
interval
A number of milliseconds, or a string with ms, s or m. Minimum 500. When omitted, the last interval passed to autoUpdate() is reused, then the auto:update value, then 2000.

Calling autoUpdate() again restarts the timer with the new interval. cancelAutoUpdate() stops it, forgets the interval and removes the auto:update attribute if present. While the user prefers reduced motion, ticks are skipped unless the doodle has ignore-reduced-motion.

Examples

const doodle = document.querySelector('css-doodle');

doodle.autoUpdate('3s');

// later
doodle.cancelAutoUpdate();

See also