How Does the SMIL min Attribute Work?
The min attribute in Synchronized Multimedia Integration
Language (SMIL) and SVG animation specifies a lower bound for an
element's active duration, guaranteeing that the animation or media
element plays for at least the designated length of time regardless of
early termination triggers or shorter intrinsic durations.
Understanding Active Duration in SMIL
In SMIL timing models, an element's runtime is governed by its simple
duration (defined by dur) and its active duration. The
active duration accounts for repetitions (repeatCount,
repeatDur), early end events (end), and parent
container constraints.
When dynamic events or explicit end attributes specify
an end time that occurs before the animation has run its desired course,
the min attribute steps in to override premature
clipping.
How the min Attribute Enforces Limits
The min attribute takes a clock value (such as
5s, 01:30, or media) and
evaluates the computed active duration against this threshold:
- When Computed Duration is Shorter than
min: If an event-based trigger, an explicitendattribute, or a shortdurwould cause the active duration to be less than theminvalue, the browser forces the active duration to extend until theminvalue is reached. - When Computed Duration Exceeds
min: If the natural active duration is already greater than the specifiedmin, the attribute has no modifying effect, and the element finishes according to its standard schedule.
Interaction with the end Attribute
The primary utility of min occurs when combined with an
end attribute triggered by external user actions, such as a
click or keypress.
Consider an element configured to end on a user click:
<animate
id="fade"
attributeName="opacity"
from="0"
to="1"
dur="10s"
end="click"
min="4s" />If the user clicks the element at two seconds into the timeline, the
end event fires immediately, but the min="4s"
attribute overrides an immediate stop. The animation continues running
until the four-second mark is reached, ensuring a minimum baseline
exposure for visual consistency.
Behavior During Extended Active Time
When min forces an animation to remain active past its
natural simple duration or past its end condition:
- Repetitions: If
repeatCountorrepeatDuris defined, the element continues repeating its cycle until theminthreshold elapses. - Freeze State: If the simple duration has completed
and no repetition is defined, the element holds its final state (similar
to
fill="freeze") for the remaining duration required to satisfy theminconstraint.