Skip to content

KeyframeKit / KeyframesFactory

Interface: KeyframesFactory

Properties

Error

ts
readonly Error: {
  KeyframesRuleNameTypeError: typeof KeyframesRuleNameTypeError;
  SourceTypeError: typeof SourceTypeError;
  StyleSheetImportError: typeof StyleSheetImportError;
};

KeyframesRuleNameTypeError

ts
readonly KeyframesRuleNameTypeError: typeof KeyframesRuleNameTypeError;

Thrown if keyframes rule name is not a string.

SourceTypeError

ts
readonly SourceTypeError: typeof SourceTypeError;

Thrown if source is not a CSSStyleSheet or a StyleSheetList.

StyleSheetImportError

ts
readonly StyleSheetImportError: typeof StyleSheetImportError;

Thrown if the stylesheet could not be imported.

Methods

getAllStyleSheetKeyframesRules()

ts
getAllStyleSheetKeyframesRules(obj: {
  in: CSSStyleSheetSource;
}): ParsedKeyframesRules;

Gets all the CSS keyframes rules in a stylesheet or stylesheet list, then converts them to Web Animations API keyframes.

Parameters

obj
in

CSSStyleSheetSource

The style sheet or style sheet list to get keyframes from.

Returns

ParsedKeyframesRules


getDocumentStyleSheetsOnLoad()

ts
getDocumentStyleSheetsOnLoad(obj?: {
  document?: Document;
}): Promise<StyleSheetList>;

Gets a document's stylesheets when it loads, or immediately returns them if it's already loaded.

Parameters

obj?
document?

Document = window.document

The document to get stylesheets from.

Returns

Promise<StyleSheetList>


getStyleSheetKeyframes()

ts
getStyleSheetKeyframes(obj: {
  in: CSSStyleSheetSource;
  of: string;
}): ParsedKeyframes | undefined;

Gets a CSS keyframes rule from a stylesheet or stylesheet list, then converts it to Web Animations API keyframes.

Parameters

obj
in

CSSStyleSheetSource

The stylesheet or stylesheet list where the rule resides.

of

string

The name of the @keyframes rule to get keyframes from.

Returns

ParsedKeyframes | undefined


importStyleSheet()

ts
importStyleSheet(url: string): Promise<CSSStyleSheet>;

Imports a stylesheet from a URL.

Parameters

url

string

The URL of the stylesheet to import.

Returns

Promise<CSSStyleSheet>

Remarks

Note: @import rules won't be resolved in imported stylesheets.
See https://github.com/WICG/construct-stylesheets/issues/119#issuecomment-588352418.


parseKeyframesRule()

ts
parseKeyframesRule(obj: {
  rule: CSSKeyframesRule;
}): ParsedKeyframes;

Converts a CSS keyframes rule to Web Animations API keyframes.

Parameters

obj
rule

CSSKeyframesRule

The rule to convert.

Returns

ParsedKeyframes

See Also

Referenced Here

References This