keyframekit 1.0.7 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +129 -126
- package/dist/KeyframeKit.d.ts +138 -138
- package/dist/KeyframeKit.js +293 -293
- package/docs/.vitepress/components/Playground/Playground.js +242 -242
- package/docs/.vitepress/components/Playground/Playground.vue +206 -206
- package/docs/.vitepress/components/Playground/defaultExample.js +175 -175
- package/docs/.vitepress/components/Playground/interFont.js +14 -14
- package/docs/.vitepress/components/Playground/themes/githubDark.js +401 -401
- package/docs/.vitepress/components/Playground/themes/githubLight.js +398 -398
- package/docs/.vitepress/components/Playground/themes.js +24 -24
- package/docs/.vitepress/config.ts +84 -69
- package/docs/.vitepress/referenceNavigation.ts +37 -37
- package/docs/.vitepress/theme/base-styles.css +100 -91
- package/docs/.vitepress/theme/env.d.ts +5 -5
- package/docs/.vitepress/theme/index.ts +39 -39
- package/docs/docs/index.md +142 -141
- package/docs/docs/public/playground/KeyframeKit/dist/KeyframeKit.d.ts +138 -138
- package/docs/docs/public/playground/KeyframeKit/dist/KeyframeKit.js +293 -293
- package/docs/docs/reference/_media/LICENSE +21 -21
- package/docs/docs/reference/classes/KeyframeEffectParameters.md +95 -95
- package/docs/docs/reference/classes/ParsedKeyframes.md +49 -49
- package/docs/docs/reference/index.md +20 -20
- package/docs/docs/reference/interfaces/KeyframesFactory.md +151 -151
- package/docs/docs/reference/navigation.json +63 -63
- package/docs/docs/reference/type-aliases/KeyframeArgument.md +9 -9
- package/docs/docs/reference/type-aliases/KeyframesFactorySource.md +9 -9
- package/docs/docs/reference/type-aliases/ParsedKeyframesRules.md +15 -15
- package/docs/docs/reference/variables/default.md +7 -7
- package/docs/package.json +25 -25
- package/docs/typedoc/plugin-param-names.js +51 -51
- package/docs/typedoc.json +62 -62
- package/package.json +37 -37
- package/src/KeyframeKit.ts +508 -508
- package/tsconfig.json +47 -47
- package/vercel.json +12 -12
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Ben Hatsor
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ben Hatsor
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,126 +1,129 @@
|
|
|
1
|
-
# <img src="/docs/docs/public/icon.png" width="30px" height="40px"> [KeyframeKit]
|
|
2
|
-
|
|
3
|
-
Intuitive, powerful and
|
|
4
|
-
|
|
5
|
-
## About
|
|
6
|
-
|
|
7
|
-
While working with the [Web Animations API][
|
|
8
|
-
|
|
9
|
-
## Installation
|
|
10
|
-
|
|
11
|
-
### NPM
|
|
12
|
-
```sh
|
|
13
|
-
npm install keyframekit
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
## Usage
|
|
17
|
-
|
|
18
|
-
### Playing CSS-defined animations with JS
|
|
19
|
-
|
|
20
|
-
In your CSS:
|
|
21
|
-
```css
|
|
22
|
-
@keyframes rotate-small { ... }
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
Then, in JS:
|
|
26
|
-
```js
|
|
27
|
-
import KeyframeKit from 'keyframekit';
|
|
28
|
-
|
|
29
|
-
const documentStyleSheets = await KeyframeKit.getDocumentStyleSheetsOnLoad();
|
|
30
|
-
|
|
31
|
-
// get animation keyframes from the document's stylesheets
|
|
32
|
-
const rotateSmallAnimKeyframes = KeyframeKit.getStyleSheetKeyframes({
|
|
33
|
-
of: 'rotate-small',
|
|
34
|
-
in: documentStyleSheets
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
// then, define your animation
|
|
38
|
-
const rotateSmallAnim = rotateSmallAnimKeyframes.toKeyframeEffect({
|
|
39
|
-
duration: 700,
|
|
40
|
-
easing: 'ease'
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
// finally, attach it to an element:
|
|
44
|
-
const attachedAnim = rotateSmallAnim.toAnimation({
|
|
45
|
-
target: document.querySelector('.el')
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
attachedAnim.play();
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
The primary reason to play your animation with JS is because you get way more control over its playback:
|
|
52
|
-
```js
|
|
53
|
-
attachedAnim.pause();
|
|
54
|
-
attachedAnim.playbackRate = -1;
|
|
55
|
-
const progress = attachedAnim.overallProgress; // 0 to 1 (Baseline newly available)
|
|
56
|
-
await attachedAnim.finished;
|
|
57
|
-
```
|
|
58
|
-
[...and more.][
|
|
59
|
-
|
|
60
|
-
### Importing animations directly from a CSS file
|
|
61
|
-
|
|
62
|
-
Instead of getting an animation from the document's stylesheets, you can also import it directly from a CSS file.
|
|
63
|
-
|
|
64
|
-
```js
|
|
65
|
-
import KeyframeKit from 'keyframekit';
|
|
66
|
-
|
|
67
|
-
const styleSheet = await KeyframeKit.importStyleSheet('./styles.css');
|
|
68
|
-
|
|
69
|
-
// get animation keyframes from stylesheet
|
|
70
|
-
const rotateSmallAnimKeyframes = KeyframeKit.getStyleSheetKeyframes({
|
|
71
|
-
of: 'rotate-small',
|
|
72
|
-
in: styleSheet
|
|
73
|
-
});
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
> Note: This won't resolve any `@import` rules in the stylesheet. [See
|
|
77
|
-
|
|
78
|
-
### Defining animations in JS
|
|
79
|
-
|
|
80
|
-
The `KeyframeEffectParameters` class provides a more convenient way to define your animations in JS than is offered natively.
|
|
81
|
-
It's useful for when you want to have all your animation code in one place.
|
|
82
|
-
|
|
83
|
-
```js
|
|
84
|
-
import { KeyframeEffectParameters } from 'keyframekit';
|
|
85
|
-
|
|
86
|
-
// define your animation
|
|
87
|
-
const linkTextHoverAnim = new KeyframeEffectParameters({
|
|
88
|
-
|
|
89
|
-
keyframes: {
|
|
90
|
-
// 0 to 1. equivalent to CSS keyframe percentage values:
|
|
91
|
-
offset: [0, 0.499, 0.5, 1],
|
|
92
|
-
// respective CSS property keyframes:
|
|
93
|
-
clipPath: ['inset(0 0 0 0)', 'inset(100% 0 0 0)', 'inset(0 0 100% 0)', 'inset(0 0 0 0)'],
|
|
94
|
-
top: ['0', '-20px', '20px', '0']
|
|
95
|
-
},
|
|
96
|
-
|
|
97
|
-
options: {
|
|
98
|
-
duration: 700,
|
|
99
|
-
easing: 'ease'
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
// then, attach it to an element:
|
|
105
|
-
const attachedAnim = linkTextHoverAnim.toAnimation({
|
|
106
|
-
target: document.querySelector('.link')
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
attachedAnim.play();
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
### Full reference
|
|
113
|
-
[See here.]
|
|
114
|
-
|
|
115
|
-
## Typing
|
|
116
|
-
|
|
117
|
-
This library is fully compatable with native JS, but it also has full spec-compliant type support, including declaration files and source maps.
|
|
118
|
-
|
|
119
|
-
## License
|
|
120
|
-
|
|
121
|
-
[MIT](LICENSE)
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
[1]: https://
|
|
125
|
-
[2]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Animations_API
|
|
126
|
-
[3]: https://
|
|
1
|
+
# <img src="/docs/docs/public/icon.png" width="30px" height="40px"> [KeyframeKit][1]
|
|
2
|
+
|
|
3
|
+
Intuitive, powerful and lightweight tools for working with CSS animations in JavaScript.
|
|
4
|
+
|
|
5
|
+
## About
|
|
6
|
+
|
|
7
|
+
While working with the [Web Animations API][2], I was surprised there wasn't an easy way to import animation keyframes directly from your CSS. You had to re-define them in JS, using a completely different format. So I wrote a typed, spec-compliant library to convert from one to the other, letting you play your CSS-defined animations right in JS. Along the way, I also added some other useful utilities for working with the API. [Read more.][3]
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
### NPM
|
|
12
|
+
```sh
|
|
13
|
+
npm install keyframekit
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
### Playing CSS-defined animations with JS
|
|
19
|
+
|
|
20
|
+
In your CSS:
|
|
21
|
+
```css
|
|
22
|
+
@keyframes rotate-small { ... }
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Then, in JS:
|
|
26
|
+
```js
|
|
27
|
+
import KeyframeKit from 'keyframekit';
|
|
28
|
+
|
|
29
|
+
const documentStyleSheets = await KeyframeKit.getDocumentStyleSheetsOnLoad();
|
|
30
|
+
|
|
31
|
+
// get animation keyframes from the document's stylesheets
|
|
32
|
+
const rotateSmallAnimKeyframes = KeyframeKit.getStyleSheetKeyframes({
|
|
33
|
+
of: 'rotate-small',
|
|
34
|
+
in: documentStyleSheets
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// then, define your animation
|
|
38
|
+
const rotateSmallAnim = rotateSmallAnimKeyframes.toKeyframeEffect({
|
|
39
|
+
duration: 700,
|
|
40
|
+
easing: 'ease'
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// finally, attach it to an element:
|
|
44
|
+
const attachedAnim = rotateSmallAnim.toAnimation({
|
|
45
|
+
target: document.querySelector('.el')
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
attachedAnim.play();
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
The primary reason to play your animation with JS is because you get way more control over its playback:
|
|
52
|
+
```js
|
|
53
|
+
attachedAnim.pause();
|
|
54
|
+
attachedAnim.playbackRate = -1;
|
|
55
|
+
const progress = attachedAnim.overallProgress; // 0 to 1 (Baseline newly available)
|
|
56
|
+
await attachedAnim.finished;
|
|
57
|
+
```
|
|
58
|
+
[...and more.][4]
|
|
59
|
+
|
|
60
|
+
### Importing animations directly from a CSS file
|
|
61
|
+
|
|
62
|
+
Instead of getting an animation from the document's stylesheets, you can also import it directly from a CSS file.
|
|
63
|
+
|
|
64
|
+
```js
|
|
65
|
+
import KeyframeKit from 'keyframekit';
|
|
66
|
+
|
|
67
|
+
const styleSheet = await KeyframeKit.importStyleSheet('./styles.css');
|
|
68
|
+
|
|
69
|
+
// get animation keyframes from stylesheet
|
|
70
|
+
const rotateSmallAnimKeyframes = KeyframeKit.getStyleSheetKeyframes({
|
|
71
|
+
of: 'rotate-small',
|
|
72
|
+
in: styleSheet
|
|
73
|
+
});
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
> Note: This won't resolve any `@import` rules in the stylesheet. [See more.][5]
|
|
77
|
+
|
|
78
|
+
### Defining animations in JS
|
|
79
|
+
|
|
80
|
+
The `KeyframeEffectParameters` class provides a more convenient way to define your animations in JS than is offered natively.
|
|
81
|
+
It's useful for when you want to have all your animation code in one place.
|
|
82
|
+
|
|
83
|
+
```js
|
|
84
|
+
import { KeyframeEffectParameters } from 'keyframekit';
|
|
85
|
+
|
|
86
|
+
// define your animation
|
|
87
|
+
const linkTextHoverAnim = new KeyframeEffectParameters({
|
|
88
|
+
|
|
89
|
+
keyframes: {
|
|
90
|
+
// 0 to 1. equivalent to CSS keyframe percentage values:
|
|
91
|
+
offset: [0, 0.499, 0.5, 1],
|
|
92
|
+
// respective CSS property keyframes:
|
|
93
|
+
clipPath: ['inset(0 0 0 0)', 'inset(100% 0 0 0)', 'inset(0 0 100% 0)', 'inset(0 0 0 0)'],
|
|
94
|
+
top: ['0', '-20px', '20px', '0']
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
options: {
|
|
98
|
+
duration: 700,
|
|
99
|
+
easing: 'ease'
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
// then, attach it to an element:
|
|
105
|
+
const attachedAnim = linkTextHoverAnim.toAnimation({
|
|
106
|
+
target: document.querySelector('.link')
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
attachedAnim.play();
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Full reference
|
|
113
|
+
[See here.][6]
|
|
114
|
+
|
|
115
|
+
## Typing
|
|
116
|
+
|
|
117
|
+
This library is fully compatable with native JS, but it also has full spec-compliant type support, including declaration files and source maps.
|
|
118
|
+
|
|
119
|
+
## License
|
|
120
|
+
|
|
121
|
+
[MIT](LICENSE)
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
[1]: https://keyframekit.berryscript.com
|
|
125
|
+
[2]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Animations_API
|
|
126
|
+
[3]: https://benhatsor.medium.com/99573ef4738b
|
|
127
|
+
[4]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Animations_API/Using_the_Web_Animations_API
|
|
128
|
+
[5]: https://github.com/WICG/construct-stylesheets/issues/119#issuecomment-588352418
|
|
129
|
+
[6]: https://keyframekit.berryscript.com/reference
|
package/dist/KeyframeKit.d.ts
CHANGED
|
@@ -1,139 +1,139 @@
|
|
|
1
|
-
export type KeyframesFactorySource = StyleSheetList | CSSStyleSheet;
|
|
2
|
-
declare class KeyframesFactory {
|
|
3
|
-
#private;
|
|
4
|
-
readonly Error: {
|
|
5
|
-
readonly KeyframesRuleNameTypeError: {
|
|
6
|
-
new (message?: string): {
|
|
7
|
-
message: string;
|
|
8
|
-
name: string;
|
|
9
|
-
stack?: string;
|
|
10
|
-
cause?: unknown;
|
|
11
|
-
};
|
|
12
|
-
new (message?: string, options?: ErrorOptions): {
|
|
13
|
-
message: string;
|
|
14
|
-
name: string;
|
|
15
|
-
stack?: string;
|
|
16
|
-
cause?: unknown;
|
|
17
|
-
};
|
|
18
|
-
new (message?: string): {
|
|
19
|
-
message: string;
|
|
20
|
-
name: string;
|
|
21
|
-
stack?: string;
|
|
22
|
-
cause?: unknown;
|
|
23
|
-
};
|
|
24
|
-
new (message?: string, options?: ErrorOptions): {
|
|
25
|
-
message: string;
|
|
26
|
-
name: string;
|
|
27
|
-
stack?: string;
|
|
28
|
-
cause?: unknown;
|
|
29
|
-
};
|
|
30
|
-
isError(error: unknown): error is Error;
|
|
31
|
-
};
|
|
32
|
-
readonly SourceTypeError: {
|
|
33
|
-
new (message?: string): {
|
|
34
|
-
message: string;
|
|
35
|
-
name: string;
|
|
36
|
-
stack?: string;
|
|
37
|
-
cause?: unknown;
|
|
38
|
-
};
|
|
39
|
-
new (message?: string, options?: ErrorOptions): {
|
|
40
|
-
message: string;
|
|
41
|
-
name: string;
|
|
42
|
-
stack?: string;
|
|
43
|
-
cause?: unknown;
|
|
44
|
-
};
|
|
45
|
-
new (message?: string): {
|
|
46
|
-
message: string;
|
|
47
|
-
name: string;
|
|
48
|
-
stack?: string;
|
|
49
|
-
cause?: unknown;
|
|
50
|
-
};
|
|
51
|
-
new (message?: string, options?: ErrorOptions): {
|
|
52
|
-
message: string;
|
|
53
|
-
name: string;
|
|
54
|
-
stack?: string;
|
|
55
|
-
cause?: unknown;
|
|
56
|
-
};
|
|
57
|
-
isError(error: unknown): error is Error;
|
|
58
|
-
};
|
|
59
|
-
readonly StyleSheetImportError: {
|
|
60
|
-
new (message?: string): {
|
|
61
|
-
message: string;
|
|
62
|
-
name: string;
|
|
63
|
-
stack?: string;
|
|
64
|
-
cause?: unknown;
|
|
65
|
-
};
|
|
66
|
-
new (message?: string, options?: ErrorOptions): {
|
|
67
|
-
message: string;
|
|
68
|
-
name: string;
|
|
69
|
-
stack?: string;
|
|
70
|
-
cause?: unknown;
|
|
71
|
-
};
|
|
72
|
-
isError(error: unknown): error is Error;
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
getDocumentStyleSheetsOnLoad({ document }?: {
|
|
76
|
-
document?: Document;
|
|
77
|
-
}): Promise<StyleSheetList>;
|
|
78
|
-
/** @remarks
|
|
79
|
-
* Note: `@import` rules won't be resolved in imported stylesheets.
|
|
80
|
-
* See https://github.com/WICG/construct-stylesheets/issues/119#issuecomment-588352418. */
|
|
81
|
-
importStyleSheet(url: string): Promise<CSSStyleSheet>;
|
|
82
|
-
/** @param obj.of The name of the `@keyframes` rule to get keyframes from. */
|
|
83
|
-
getStyleSheetKeyframes({ of: ruleName, in: source }: {
|
|
84
|
-
of: string;
|
|
85
|
-
in: KeyframesFactorySource;
|
|
86
|
-
}): ParsedKeyframes | undefined;
|
|
87
|
-
getAllStyleSheetKeyframesRules({ in: source }: {
|
|
88
|
-
in: KeyframesFactorySource;
|
|
89
|
-
}): ParsedKeyframesRules;
|
|
90
|
-
parseKeyframesRule({ rule: keyframes }: {
|
|
91
|
-
rule: CSSKeyframesRule;
|
|
92
|
-
}): ParsedKeyframes;
|
|
93
|
-
}
|
|
94
|
-
declare const _default: KeyframesFactory;
|
|
95
|
-
export default _default;
|
|
96
|
-
export type { KeyframesFactory };
|
|
97
|
-
/** https://drafts.csswg.org/web-animations-1/#processing-a-keyframes-argument */
|
|
98
|
-
export type KeyframeArgument = Keyframe[] | PropertyIndexedKeyframes;
|
|
99
|
-
/** https://drafts.csswg.org/web-animations-1/#the-keyframeeffect-interface */
|
|
100
|
-
export declare class KeyframeEffectParameters {
|
|
101
|
-
#private;
|
|
102
|
-
keyframes: KeyframeArgument;
|
|
103
|
-
options: KeyframeEffectOptions;
|
|
104
|
-
/**
|
|
105
|
-
* @param obj.keyframes [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Web_Animations_API/Keyframe_Formats)
|
|
106
|
-
* @param obj.options [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/KeyframeEffect/KeyframeEffect#options)
|
|
107
|
-
*/
|
|
108
|
-
constructor({ keyframes, options }: {
|
|
109
|
-
keyframes: KeyframeArgument;
|
|
110
|
-
options?: number | KeyframeEffectOptions;
|
|
111
|
-
});
|
|
112
|
-
/**
|
|
113
|
-
* @param obj.target An element to attach the animation to.
|
|
114
|
-
* @param obj.options Additional keyframe effect options. Can override existing keys.
|
|
115
|
-
* [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/KeyframeEffect/KeyframeEffect#options)
|
|
116
|
-
*
|
|
117
|
-
* @see Specifications:
|
|
118
|
-
* - https://drafts.csswg.org/web-animations-1/#the-keyframeeffect-interface
|
|
119
|
-
* - https://drafts.csswg.org/web-animations-1/#the-animation-interface
|
|
120
|
-
*/
|
|
121
|
-
toAnimation({ target, options: additionalOptions, timeline }: {
|
|
122
|
-
target: Element | null;
|
|
123
|
-
options?: number | KeyframeEffectOptions;
|
|
124
|
-
timeline?: AnimationTimeline;
|
|
125
|
-
}): Animation;
|
|
126
|
-
}
|
|
127
|
-
export declare class ParsedKeyframes {
|
|
128
|
-
keyframes: Keyframe[];
|
|
129
|
-
constructor(keyframes: Keyframe[]);
|
|
130
|
-
/**
|
|
131
|
-
* @param options
|
|
132
|
-
* [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/KeyframeEffect/KeyframeEffect#options)
|
|
133
|
-
*/
|
|
134
|
-
toKeyframeEffect(options: number | KeyframeEffectOptions | null): KeyframeEffectParameters;
|
|
135
|
-
}
|
|
136
|
-
export type ParsedKeyframesRules = {
|
|
137
|
-
[ruleName: string]: ParsedKeyframes;
|
|
138
|
-
};
|
|
1
|
+
export type KeyframesFactorySource = StyleSheetList | CSSStyleSheet;
|
|
2
|
+
declare class KeyframesFactory {
|
|
3
|
+
#private;
|
|
4
|
+
readonly Error: {
|
|
5
|
+
readonly KeyframesRuleNameTypeError: {
|
|
6
|
+
new (message?: string): {
|
|
7
|
+
message: string;
|
|
8
|
+
name: string;
|
|
9
|
+
stack?: string;
|
|
10
|
+
cause?: unknown;
|
|
11
|
+
};
|
|
12
|
+
new (message?: string, options?: ErrorOptions): {
|
|
13
|
+
message: string;
|
|
14
|
+
name: string;
|
|
15
|
+
stack?: string;
|
|
16
|
+
cause?: unknown;
|
|
17
|
+
};
|
|
18
|
+
new (message?: string): {
|
|
19
|
+
message: string;
|
|
20
|
+
name: string;
|
|
21
|
+
stack?: string;
|
|
22
|
+
cause?: unknown;
|
|
23
|
+
};
|
|
24
|
+
new (message?: string, options?: ErrorOptions): {
|
|
25
|
+
message: string;
|
|
26
|
+
name: string;
|
|
27
|
+
stack?: string;
|
|
28
|
+
cause?: unknown;
|
|
29
|
+
};
|
|
30
|
+
isError(error: unknown): error is Error;
|
|
31
|
+
};
|
|
32
|
+
readonly SourceTypeError: {
|
|
33
|
+
new (message?: string): {
|
|
34
|
+
message: string;
|
|
35
|
+
name: string;
|
|
36
|
+
stack?: string;
|
|
37
|
+
cause?: unknown;
|
|
38
|
+
};
|
|
39
|
+
new (message?: string, options?: ErrorOptions): {
|
|
40
|
+
message: string;
|
|
41
|
+
name: string;
|
|
42
|
+
stack?: string;
|
|
43
|
+
cause?: unknown;
|
|
44
|
+
};
|
|
45
|
+
new (message?: string): {
|
|
46
|
+
message: string;
|
|
47
|
+
name: string;
|
|
48
|
+
stack?: string;
|
|
49
|
+
cause?: unknown;
|
|
50
|
+
};
|
|
51
|
+
new (message?: string, options?: ErrorOptions): {
|
|
52
|
+
message: string;
|
|
53
|
+
name: string;
|
|
54
|
+
stack?: string;
|
|
55
|
+
cause?: unknown;
|
|
56
|
+
};
|
|
57
|
+
isError(error: unknown): error is Error;
|
|
58
|
+
};
|
|
59
|
+
readonly StyleSheetImportError: {
|
|
60
|
+
new (message?: string): {
|
|
61
|
+
message: string;
|
|
62
|
+
name: string;
|
|
63
|
+
stack?: string;
|
|
64
|
+
cause?: unknown;
|
|
65
|
+
};
|
|
66
|
+
new (message?: string, options?: ErrorOptions): {
|
|
67
|
+
message: string;
|
|
68
|
+
name: string;
|
|
69
|
+
stack?: string;
|
|
70
|
+
cause?: unknown;
|
|
71
|
+
};
|
|
72
|
+
isError(error: unknown): error is Error;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
getDocumentStyleSheetsOnLoad({ document }?: {
|
|
76
|
+
document?: Document;
|
|
77
|
+
}): Promise<StyleSheetList>;
|
|
78
|
+
/** @remarks
|
|
79
|
+
* Note: `@import` rules won't be resolved in imported stylesheets.
|
|
80
|
+
* See https://github.com/WICG/construct-stylesheets/issues/119#issuecomment-588352418. */
|
|
81
|
+
importStyleSheet(url: string): Promise<CSSStyleSheet>;
|
|
82
|
+
/** @param obj.of The name of the `@keyframes` rule to get keyframes from. */
|
|
83
|
+
getStyleSheetKeyframes({ of: ruleName, in: source }: {
|
|
84
|
+
of: string;
|
|
85
|
+
in: KeyframesFactorySource;
|
|
86
|
+
}): ParsedKeyframes | undefined;
|
|
87
|
+
getAllStyleSheetKeyframesRules({ in: source }: {
|
|
88
|
+
in: KeyframesFactorySource;
|
|
89
|
+
}): ParsedKeyframesRules;
|
|
90
|
+
parseKeyframesRule({ rule: keyframes }: {
|
|
91
|
+
rule: CSSKeyframesRule;
|
|
92
|
+
}): ParsedKeyframes;
|
|
93
|
+
}
|
|
94
|
+
declare const _default: KeyframesFactory;
|
|
95
|
+
export default _default;
|
|
96
|
+
export type { KeyframesFactory };
|
|
97
|
+
/** https://drafts.csswg.org/web-animations-1/#processing-a-keyframes-argument */
|
|
98
|
+
export type KeyframeArgument = Keyframe[] | PropertyIndexedKeyframes;
|
|
99
|
+
/** https://drafts.csswg.org/web-animations-1/#the-keyframeeffect-interface */
|
|
100
|
+
export declare class KeyframeEffectParameters {
|
|
101
|
+
#private;
|
|
102
|
+
keyframes: KeyframeArgument;
|
|
103
|
+
options: KeyframeEffectOptions;
|
|
104
|
+
/**
|
|
105
|
+
* @param obj.keyframes [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Web_Animations_API/Keyframe_Formats)
|
|
106
|
+
* @param obj.options [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/KeyframeEffect/KeyframeEffect#options)
|
|
107
|
+
*/
|
|
108
|
+
constructor({ keyframes, options }: {
|
|
109
|
+
keyframes: KeyframeArgument;
|
|
110
|
+
options?: number | KeyframeEffectOptions;
|
|
111
|
+
});
|
|
112
|
+
/**
|
|
113
|
+
* @param obj.target An element to attach the animation to.
|
|
114
|
+
* @param obj.options Additional keyframe effect options. Can override existing keys.
|
|
115
|
+
* [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/KeyframeEffect/KeyframeEffect#options)
|
|
116
|
+
*
|
|
117
|
+
* @see Specifications:
|
|
118
|
+
* - https://drafts.csswg.org/web-animations-1/#the-keyframeeffect-interface
|
|
119
|
+
* - https://drafts.csswg.org/web-animations-1/#the-animation-interface
|
|
120
|
+
*/
|
|
121
|
+
toAnimation({ target, options: additionalOptions, timeline }: {
|
|
122
|
+
target: Element | null;
|
|
123
|
+
options?: number | KeyframeEffectOptions;
|
|
124
|
+
timeline?: AnimationTimeline;
|
|
125
|
+
}): Animation;
|
|
126
|
+
}
|
|
127
|
+
export declare class ParsedKeyframes {
|
|
128
|
+
keyframes: Keyframe[];
|
|
129
|
+
constructor(keyframes: Keyframe[]);
|
|
130
|
+
/**
|
|
131
|
+
* @param options
|
|
132
|
+
* [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/KeyframeEffect/KeyframeEffect#options)
|
|
133
|
+
*/
|
|
134
|
+
toKeyframeEffect(options: number | KeyframeEffectOptions | null): KeyframeEffectParameters;
|
|
135
|
+
}
|
|
136
|
+
export type ParsedKeyframesRules = {
|
|
137
|
+
[ruleName: string]: ParsedKeyframes;
|
|
138
|
+
};
|
|
139
139
|
//# sourceMappingURL=KeyframeKit.d.ts.map
|