KeyframeEffect Class

An animation effect that animates the properties of an element with keyframes (https://drafts.csswg.org/web-animations-1/#keyframe-effects).

public class KeyframeEffect : AnimationEffect
Inheritance
AnimationEffect KeyframeEffect

Constructors

NameDescription
KeyframeEffect(KeyframeEffect)Creates a copy of a keyframe effect (https://drafts.csswg.org/web-animations-1/#dom-keyframeeffect-keyframeeffect-source).
KeyframeEffect(Element?, IEnumerable<Keyframe>?, KeyframeEffectOptions?)Creates a keyframe effect (https://drafts.csswg.org/web-animations-1/#dom-keyframeeffect-keyframeeffect).
KeyframeEffect(Element?, IEnumerable<Keyframe>?, double)Creates a keyframe effect whose duration is duration milliseconds (https://drafts.csswg.org/web-animations-1/#dom-keyframeeffect-keyframeeffect).

KeyframeEffect overloads

KeyframeEffect(KeyframeEffect)

KeyframeEffect.cs

Creates a copy of a keyframe effect (https://drafts.csswg.org/web-animations-1/#dom-keyframeeffect-keyframeeffect-source).

public KeyframeEffect(KeyframeEffect source)

KeyframeEffect(Element?, IEnumerable<Keyframe>?, KeyframeEffectOptions?)

KeyframeEffect.cs

Creates a keyframe effect (https://drafts.csswg.org/web-animations-1/#dom-keyframeeffect-keyframeeffect).

public KeyframeEffect(Element? target, IEnumerable<Keyframe>? keyframes, KeyframeEffectOptions? options = null)
Parameters
target Element?
keyframes IEnumerable<Keyframe>?
options KeyframeEffectOptions?
Exceptions
TypeErrorException
The keyframes or the timing properties are invalid.
DomException
The pseudo-element is invalid (SyntaxError).
See also

KeyframeEffect(Element?, IEnumerable<Keyframe>?, double)

KeyframeEffect.cs

Creates a keyframe effect whose duration is duration milliseconds (https://drafts.csswg.org/web-animations-1/#dom-keyframeeffect-keyframeeffect).

public KeyframeEffect(Element? target, IEnumerable<Keyframe>? keyframes, double duration)
Parameters
target Element?
keyframes IEnumerable<Keyframe>?
duration double
Exceptions
TypeErrorException
The keyframes or the duration are invalid.
See also

Properties

NameDescription
CompositeGets or sets the composite operation of the effect (https://drafts.csswg.org/web-animations-1/#dom-keyframeeffect-composite).
IterationCompositeGets or sets the iteration composite operation of the effect (https://drafts.csswg.org/web-animations-2/#dom-keyframeeffect-iterationcomposite).
PseudoElementGets or sets the pseudo-element targeted by the effect, or null to target the element (https://drafts.csswg.org/web-animations-1/#dom-keyframeeffect-pseudoelement).
TargetGets or sets the element targeted by the effect (https://drafts.csswg.org/web-animations-1/#dom-keyframeeffect-target).

Gets or sets the composite operation of the effect (https://drafts.csswg.org/web-animations-1/#dom-keyframeeffect-composite).

public CompositeOperation Composite { get; set; }

IterationComposite

KeyframeEffect.cs

Gets or sets the iteration composite operation of the effect (https://drafts.csswg.org/web-animations-2/#dom-keyframeeffect-iterationcomposite).

public IterationCompositeOperation IterationComposite { get; set; }

PseudoElement

KeyframeEffect.cs

Gets or sets the pseudo-element targeted by the effect, or null to target the element (https://drafts.csswg.org/web-animations-1/#dom-keyframeeffect-pseudoelement).

public string? PseudoElement { get; set; }

Property value

string?

Exceptions

DomException
The pseudo-element is invalid (SyntaxError).

See also

Gets or sets the element targeted by the effect (https://drafts.csswg.org/web-animations-1/#dom-keyframeeffect-target).

public Element? Target { get; set; }

Methods

NameDescription
GetKeyframes()Returns the keyframes of the effect (https://drafts.csswg.org/web-animations-1/#dom-keyframeeffect-getkeyframes).
SetKeyframes(IEnumerable<Keyframe>?)Replaces the keyframes of the effect (https://drafts.csswg.org/web-animations-1/#dom-keyframeeffect-setkeyframes).

GetKeyframes()

KeyframeEffect.cs

Returns the keyframes of the effect (https://drafts.csswg.org/web-animations-1/#dom-keyframeeffect-getkeyframes).

public IReadOnlyList<ComputedKeyframe> GetKeyframes()

SetKeyframes(IEnumerable<Keyframe>?)

KeyframeEffect.cs

Replaces the keyframes of the effect (https://drafts.csswg.org/web-animations-1/#dom-keyframeeffect-setkeyframes).

public void SetKeyframes(IEnumerable<Keyframe>? keyframes)