RepeatCount vs RepeatDur in SMIL: What Is the Difference?

In Synchronized Multimedia Integration Language (SMIL) and SVG animations, repeatCount and repeatDur both control how long an animation loops, but they determine the ending condition through different metrics. While repeatCount specifies repetition based on the exact number of cycles completed, repeatDur defines the total clock time during which the animation is allowed to repeat. Choosing between them dictates whether an animation finishes cleanly at the end of a full loop or stops strictly when a specific duration elapses.

Defining the Parameters

Both attributes are part of the SMIL timing model used within SVG animation elements such as <animate>, <animateTransform>, and <animateMotion>.

The repeatCount Attribute

The repeatCount attribute defines the number of iterations an animation executes.

The repeatDur Attribute

The repeatDur attribute specifies the total accumulated clock time for which the animation is permitted to repeat.

Key Functional Differences

The practical differences between both attributes appear most clearly across cycle alignment, timing dependencies, and interaction when used together.

Cycle Alignment and Truncation

Behavior When Duration (dur) Changes

Combining repeatCount and repeatDur

When both repeatCount and repeatDur are defined on the same animation element, SMIL rules dictate that the active repetition period ends at whichever constraint is reached first.

For example, consider an element with dur="2s", repeatCount="5", and repeatDur="6s":

Because 6 seconds is shorter than 10 seconds, the animation stops repeating after 6 seconds (completing exactly 3 cycles).