Back to Content

AnimationEffect: updateTiming() method

files/en-us/web/api/animationeffect/updatetiming/index.md

latest1.5 KB
Original Source

{{ APIRef("Web Animations") }}

The updateTiming() method of the {{domxref("AnimationEffect")}} interface updates the specified timing properties for an animation effect.

Syntax

js-nolint
updateTiming(timing)

Parameters

  • timing {{optional_inline}}
    • : An object containing zero or more of the properties from the return value of {{domxref("AnimationEffect.getTiming()")}}, representing the timing properties to update.

Return value

None ({{jsxref("undefined")}}).

Exceptions

  • {{jsxref("TypeError")}}
    • : Thrown if invalid values are provided for any of the timing properties.

Examples

Side effects

updateTiming() may cause any associated {{domxref("Animation")}} to start or stop playing, if for example the effect of a running animation is shortened such that its end time is before {{domxref("Animation.currentTime")}} or the effect of a finished animation is lengthened such that its end time is after {{domxref("Animation.currentTime")}}.

js
const animation = document.body.animate([], { duration: 1000 });
animation.finish();
console.log(animation.playState); // finished
animation.effect.updateTiming({ duration: 2000 });
console.log(animation.playState); // running

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also

  • Web Animations API
  • {{domxref("AnimationEffect")}}
  • {{domxref("Animation")}}
  • {{domxref("AnimationEffect.getTiming()")}}
  • {{domxref("AnimationEffect.getComputedTiming()")}}