keyframekit 1.1.9 → 1.2.1

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.
Files changed (46) hide show
  1. package/README.md +8 -1
  2. package/dist/KeyframeKit.d.ts +3 -3
  3. package/dist/KeyframeKit.d.ts.map +1 -1
  4. package/dist/KeyframeKit.js +3 -3
  5. package/dist/KeyframeKit.js.map +1 -1
  6. package/dist/KeyframeKit.min.js +1 -0
  7. package/dist/KeyframeKit.min.js.map +1 -0
  8. package/package.json +7 -4
  9. package/src/KeyframeKit.ts +6 -6
  10. package/docs/.vitepress/components/Playground/Playground.js +0 -243
  11. package/docs/.vitepress/components/Playground/Playground.vue +0 -208
  12. package/docs/.vitepress/components/Playground/defaultExample.js +0 -175
  13. package/docs/.vitepress/components/Playground/interFont.js +0 -14
  14. package/docs/.vitepress/components/Playground/themes/githubDark.js +0 -402
  15. package/docs/.vitepress/components/Playground/themes/githubLight.js +0 -399
  16. package/docs/.vitepress/components/Playground/themes.js +0 -24
  17. package/docs/.vitepress/config.ts +0 -87
  18. package/docs/.vitepress/referenceNavigation.ts +0 -37
  19. package/docs/.vitepress/theme/base-styles.css +0 -104
  20. package/docs/.vitepress/theme/env.d.ts +0 -5
  21. package/docs/.vitepress/theme/index.ts +0 -40
  22. package/docs/docs/get-started.md +0 -133
  23. package/docs/docs/index.md +0 -17
  24. package/docs/docs/public/icon.png +0 -0
  25. package/docs/docs/public/og-image.png +0 -0
  26. package/docs/docs/public/playground/KeyframeKit/dist/KeyframeKit.d.ts +0 -172
  27. package/docs/docs/public/playground/KeyframeKit/dist/KeyframeKit.d.ts.map +0 -1
  28. package/docs/docs/public/playground/KeyframeKit/dist/KeyframeKit.js +0 -327
  29. package/docs/docs/public/playground/KeyframeKit/dist/KeyframeKit.js.map +0 -1
  30. package/docs/docs/reference/classes/KeyframeEffectParameters.md +0 -97
  31. package/docs/docs/reference/classes/ParsedKeyframes.md +0 -49
  32. package/docs/docs/reference/index.md +0 -20
  33. package/docs/docs/reference/interfaces/KeyframesFactory.md +0 -180
  34. package/docs/docs/reference/navigation.json +0 -64
  35. package/docs/docs/reference/type-aliases/CSSStyleSheetSource.md +0 -7
  36. package/docs/docs/reference/type-aliases/KeyframeArgument.md +0 -9
  37. package/docs/docs/reference/type-aliases/ParsedKeyframesRules.md +0 -15
  38. package/docs/docs/reference/variables/default.md +0 -7
  39. package/docs/package-lock.json +0 -2321
  40. package/docs/package.json +0 -22
  41. package/docs/typedoc/plugin-markdown-mdn-links-fix.js +0 -43
  42. package/docs/typedoc/plugin-param-names.js +0 -17
  43. package/docs/typedoc.config.js +0 -78
  44. package/rollup.config.js +0 -42
  45. package/tsconfig.json +0 -47
  46. package/vercel.json +0 -14
@@ -1,40 +0,0 @@
1
- import type { EnhanceAppContext } from 'vitepress'
2
-
3
- import DefaultTheme from 'vitepress/theme'
4
-
5
- import Playground from '../components/Playground/Playground.vue'
6
-
7
- import './base-styles.css'
8
-
9
- export default {
10
- extends: DefaultTheme,
11
- enhanceApp({ app }: EnhanceAppContext) {
12
-
13
- /* if (typeof window !== 'undefined') {
14
- window.MonacoEnvironment = {
15
- getWorkerUrl(_moduleId: string, label: string): string {
16
- const base = '/monacoeditorwork/'
17
-
18
- if (label === 'typescript' || label === 'javascript') {
19
- return `${base}ts.worker.bundle.js`
20
- }
21
- if (label === 'json') {
22
- return `${base}json.worker.bundle.js`
23
- }
24
- if (label === 'css' || label === 'scss' || label === 'less') {
25
- return `${base}css.worker.bundle.js`
26
- }
27
- if (label === 'html' || label === 'handlebars' || label === 'razor') {
28
- return `${base}html.worker.bundle.js`
29
- }
30
-
31
- return `${base}editor.worker.bundle.js`
32
- }
33
- }
34
- } */
35
-
36
-
37
- app.component('Playground', Playground)
38
-
39
- }
40
- }
@@ -1,133 +0,0 @@
1
-
2
- # Get Started
3
-
4
- ## About
5
-
6
- The [Web Animations API][1] opens the browser's animation engine to developers and provides unprecedented control and performance when animating on the web. But confusingly, it provides no easy way to use your existing CSS animations with the API. So I wrote a lightweight, typed, spec-compliant library to convert stylesheet keyframes to Web Animations API-compatible animations, letting you play your CSS-defined animations right in JS. [Read more.][2]
7
-
8
- ## Installation
9
-
10
- ::: code-group
11
- ```sh [npm]
12
- npm install keyframekit
13
- ```
14
- ```sh [yarn]
15
- yarn add keyframekit
16
- ```
17
- ```sh [pnpm]
18
- pnpm add keyframekit
19
- ```
20
- :::
21
-
22
- ## Usage
23
-
24
- ### Playing CSS-defined animations with JS
25
-
26
- In your CSS:
27
- ```css
28
- @keyframes rotate-small { ... }
29
- ```
30
-
31
- Then, in JS:
32
- ```js
33
- import KeyframeKit from 'keyframekit';
34
-
35
- const documentStyleSheets = await KeyframeKit.getDocumentStyleSheetsOnLoad();
36
-
37
- // get animation keyframes from the document's stylesheets
38
- const rotateSmallAnimKeyframes = KeyframeKit.getStyleSheetKeyframes({
39
- of: 'rotate-small',
40
- in: documentStyleSheets
41
- });
42
-
43
- // then, define your animation
44
- const rotateSmallAnim = rotateSmallAnimKeyframes.toKeyframeEffect({
45
- duration: 700,
46
- easing: 'ease'
47
- });
48
-
49
- // finally, attach it to an element:
50
- const attachedAnim = rotateSmallAnim.toAnimation({
51
- target: document.querySelector('.el')
52
- });
53
-
54
- attachedAnim.play();
55
- ```
56
-
57
- The primary reason to play your animation with JS is because you get way more control over its playback:
58
- ```js
59
- attachedAnim.pause();
60
- attachedAnim.playbackRate = -1;
61
- const progress = attachedAnim.overallProgress; // 0 to 1 (Baseline newly available)
62
- await attachedAnim.finished;
63
- ```
64
- [...and more.][3]
65
-
66
- ### Importing animations directly from a CSS file
67
-
68
- Instead of getting an animation from the document's stylesheets, you can also import it directly from a CSS file.
69
-
70
- ```js
71
- import KeyframeKit from 'keyframekit';
72
-
73
- const styleSheet = await KeyframeKit.importStyleSheet('./styles.css');
74
-
75
- // get animation keyframes from stylesheet
76
- const rotateSmallAnimKeyframes = KeyframeKit.getStyleSheetKeyframes({
77
- of: 'rotate-small',
78
- in: styleSheet
79
- });
80
- ```
81
-
82
- > Note: This won't resolve any `@import` rules in the stylesheet. [See more.][4]
83
-
84
- ### Defining animations in JS
85
-
86
- The [`KeyframeEffectParameters`](reference/classes/KeyframeEffectParameters.md) class provides a more convenient way to define your animations in JS than is offered natively.
87
- It's useful for when you want to have all your animation code in one place.
88
-
89
- ```js
90
- import { KeyframeEffectParameters } from 'keyframekit';
91
-
92
- // define your animation
93
- const linkTextHoverAnim = new KeyframeEffectParameters({
94
-
95
- keyframes: {
96
- // 0 to 1. equivalent to CSS keyframe percentage values:
97
- offset: [0, 0.499, 0.5, 1],
98
- // respective CSS property keyframes:
99
- clipPath: ['inset(0 0 0 0)', 'inset(100% 0 0 0)', 'inset(0 0 100% 0)', 'inset(0 0 0 0)'],
100
- top: ['0', '-20px', '20px', '0']
101
- },
102
-
103
- options: {
104
- duration: 700,
105
- easing: 'ease'
106
- }
107
-
108
- });
109
-
110
- // then, attach it to an element:
111
- const attachedAnim = linkTextHoverAnim.toAnimation({
112
- target: document.querySelector('.link')
113
- });
114
-
115
- attachedAnim.play();
116
- ```
117
-
118
- ### Full reference
119
- [See here.](/reference/index.md)
120
-
121
- ## Typing
122
-
123
- This library is fully compatable with native JS, but it also has full spec-compliant type support, including declaration files and source maps.
124
-
125
- ## License
126
-
127
- [MIT](https://github.com/benhatsor/KeyframeKit/blob/main/LICENSE)
128
-
129
-
130
- [1]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Animations_API
131
- [2]: https://benhatsor.medium.com/99573ef4738b
132
- [3]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Animations_API/Using_the_Web_Animations_API
133
- [4]: https://github.com/WICG/construct-stylesheets/issues/119#issuecomment-588352418
@@ -1,17 +0,0 @@
1
- ---
2
- # https://vitepress.dev/reference/default-theme-home-page
3
- layout: home
4
-
5
- hero:
6
- name: KeyframeKit
7
- tagline: Unlock fine-grained control over your CSS animations with JavaScript.
8
- actions:
9
- - theme: brand
10
- text: Get Started
11
- link: /get-started
12
- - theme: alt
13
- text: Reference
14
- link: /reference
15
- ---
16
-
17
- <Playground/>
Binary file
Binary file
@@ -1,172 +0,0 @@
1
- export type CSSStyleSheetSource = CSSStyleSheet | StyleSheetList;
2
- declare class KeyframesFactory {
3
- #private;
4
- readonly Error: {
5
- /** Keyframes rule name must be a string. */
6
- readonly KeyframesRuleNameTypeError: {
7
- new (message?: string): {
8
- message: string;
9
- name: string;
10
- stack?: string;
11
- cause?: unknown;
12
- };
13
- new (message?: string, options?: ErrorOptions): {
14
- message: string;
15
- name: string;
16
- stack?: string;
17
- cause?: unknown;
18
- };
19
- new (message?: string): {
20
- message: string;
21
- name: string;
22
- stack?: string;
23
- cause?: unknown;
24
- };
25
- new (message?: string, options?: ErrorOptions): {
26
- message: string;
27
- name: string;
28
- stack?: string;
29
- cause?: unknown;
30
- };
31
- isError(error: unknown): error is Error;
32
- };
33
- /** Source must be either a `CSSStyleSheet` or a `StyleSheetList`. */
34
- readonly SourceTypeError: {
35
- new (message?: string): {
36
- message: string;
37
- name: string;
38
- stack?: string;
39
- cause?: unknown;
40
- };
41
- new (message?: string, options?: ErrorOptions): {
42
- message: string;
43
- name: string;
44
- stack?: string;
45
- cause?: unknown;
46
- };
47
- new (message?: string): {
48
- message: string;
49
- name: string;
50
- stack?: string;
51
- cause?: unknown;
52
- };
53
- new (message?: string, options?: ErrorOptions): {
54
- message: string;
55
- name: string;
56
- stack?: string;
57
- cause?: unknown;
58
- };
59
- isError(error: unknown): error is Error;
60
- };
61
- /** The stylesheet could not be imported. */
62
- readonly StyleSheetImportError: {
63
- new (message?: string): {
64
- message: string;
65
- name: string;
66
- stack?: string;
67
- cause?: unknown;
68
- };
69
- new (message?: string, options?: ErrorOptions): {
70
- message: string;
71
- name: string;
72
- stack?: string;
73
- cause?: unknown;
74
- };
75
- isError(error: unknown): error is Error;
76
- };
77
- };
78
- /**
79
- * Gets a document's stylesheets when it loads,
80
- * or immediately returns them if it's already loaded.
81
- * @param obj
82
- * @param obj.document The document to get stylesheets from.
83
- */
84
- getDocumentStyleSheetsOnLoad({ document }?: {
85
- document?: Document;
86
- }): Promise<StyleSheetList>;
87
- /**
88
- * Imports a stylesheet from a URL.
89
- * @param url The URL of the stylesheet to import.
90
- * @remarks
91
- * Note: `@import` rules won't be resolved in imported stylesheets.
92
- * See https://github.com/WICG/construct-stylesheets/issues/119#issuecomment-588352418.
93
- */
94
- importStyleSheet(url: string): Promise<CSSStyleSheet>;
95
- /**
96
- * Gets a CSS keyframes rule from a stylesheet or stylesheet list,
97
- * then converts it to Web Animations API keyframes.
98
- * @param obj
99
- * @param obj.of The name of the `@keyframes` rule to get keyframes from.
100
- * @param obj.in The stylesheet or stylesheet list where the rule resides.
101
- */
102
- getStyleSheetKeyframes({ of: ruleName, in: source }: {
103
- of: string;
104
- in: CSSStyleSheetSource;
105
- }): ParsedKeyframes | undefined;
106
- /**
107
- * Gets all the CSS keyframes rules in a stylesheet or stylesheet list,
108
- * then converts them to Web Animations API keyframes.
109
- * @param obj
110
- * @param obj.in The style sheet or style sheet list to get keyframes from.
111
- */
112
- getAllStyleSheetKeyframesRules({ in: source }: {
113
- in: CSSStyleSheetSource;
114
- }): ParsedKeyframesRules;
115
- /**
116
- * Converts a CSS keyframes rule to Web Animations API keyframes.
117
- * @param obj
118
- * @param obj.rule The rule to convert.
119
- */
120
- parseKeyframesRule({ rule: keyframes }: {
121
- rule: CSSKeyframesRule;
122
- }): ParsedKeyframes;
123
- }
124
- declare const _default: KeyframesFactory;
125
- export default _default;
126
- export type { KeyframesFactory };
127
- /** https://drafts.csswg.org/web-animations-1/#processing-a-keyframes-argument */
128
- export type KeyframeArgument = Keyframe[] | PropertyIndexedKeyframes;
129
- /** https://drafts.csswg.org/web-animations-1/#the-keyframeeffect-interface */
130
- export declare class KeyframeEffectParameters {
131
- #private;
132
- keyframes: KeyframeArgument;
133
- options: KeyframeEffectOptions;
134
- /**
135
- * @param obj
136
- * @param obj.keyframes [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Web_Animations_API/Keyframe_Formats)
137
- * @param obj.options [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/KeyframeEffect/KeyframeEffect#options)
138
- */
139
- constructor({ keyframes, options }: {
140
- keyframes: KeyframeArgument;
141
- options?: number | KeyframeEffectOptions;
142
- });
143
- /**
144
- * @param obj
145
- * @param obj.target An element to attach the animation to.
146
- * @param obj.options Additional keyframe effect options. Can override existing keys.
147
- * [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/KeyframeEffect/KeyframeEffect#options)
148
- * @param obj.timeline [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Animation/Animation#timeline)
149
- *
150
- * @see Specifications:
151
- * - https://drafts.csswg.org/web-animations-1/#the-keyframeeffect-interface
152
- * - https://drafts.csswg.org/web-animations-1/#the-animation-interface
153
- */
154
- toAnimation({ target, options: additionalOptions, timeline }: {
155
- target: Element | null;
156
- options?: number | KeyframeEffectOptions;
157
- timeline?: AnimationTimeline | null;
158
- }): Animation;
159
- }
160
- export declare class ParsedKeyframes {
161
- keyframes: Keyframe[];
162
- constructor(keyframes: Keyframe[]);
163
- /**
164
- * @param options
165
- * [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/KeyframeEffect/KeyframeEffect#options)
166
- */
167
- toKeyframeEffect(options: number | KeyframeEffectOptions | null): KeyframeEffectParameters;
168
- }
169
- export type ParsedKeyframesRules = {
170
- [ruleName: string]: ParsedKeyframes;
171
- };
172
- //# sourceMappingURL=KeyframeKit.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"KeyframeKit.d.ts","sourceRoot":"","sources":["../src/KeyframeKit.ts"],"names":[],"mappings":"AAgBA,MAAM,MAAM,mBAAmB,GAAG,aAAa,GAAG,cAAc,CAAC;AAEjE,cAAM,gBAAgB;;IAEpB,QAAQ,CAAC,KAAK;QACZ,4CAA4C;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAI5C,qEAAqE;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAIrE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