keyframekit 1.2.0 → 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 (43) hide show
  1. package/dist/KeyframeKit.min.js +1 -0
  2. package/dist/KeyframeKit.min.js.map +1 -0
  3. package/package.json +6 -3
  4. package/docs/.vitepress/components/Playground/Playground.js +0 -243
  5. package/docs/.vitepress/components/Playground/Playground.vue +0 -208
  6. package/docs/.vitepress/components/Playground/defaultExample.js +0 -175
  7. package/docs/.vitepress/components/Playground/interFont.js +0 -14
  8. package/docs/.vitepress/components/Playground/themes/githubDark.js +0 -402
  9. package/docs/.vitepress/components/Playground/themes/githubLight.js +0 -399
  10. package/docs/.vitepress/components/Playground/themes.js +0 -24
  11. package/docs/.vitepress/config.ts +0 -136
  12. package/docs/.vitepress/referenceNavigation.ts +0 -37
  13. package/docs/.vitepress/theme/base-styles.css +0 -147
  14. package/docs/.vitepress/theme/env.d.ts +0 -5
  15. package/docs/.vitepress/theme/index.ts +0 -40
  16. package/docs/docs/get-started.md +0 -131
  17. package/docs/docs/index.md +0 -17
  18. package/docs/docs/public/icon.png +0 -0
  19. package/docs/docs/public/og-image.png +0 -0
  20. package/docs/docs/public/playground/KeyframeKit/dist/KeyframeKit.d.ts +0 -172
  21. package/docs/docs/public/playground/KeyframeKit/dist/KeyframeKit.d.ts.map +0 -1
  22. package/docs/docs/public/playground/KeyframeKit/dist/KeyframeKit.js +0 -327
  23. package/docs/docs/public/playground/KeyframeKit/dist/KeyframeKit.js.map +0 -1
  24. package/docs/docs/public/playground/KeyframeKit/dist/KeyframeKit.min.js +0 -5
  25. package/docs/docs/reference/classes/KeyframeEffectParameters.md +0 -104
  26. package/docs/docs/reference/classes/ParsedKeyframes.md +0 -58
  27. package/docs/docs/reference/index.md +0 -20
  28. package/docs/docs/reference/interfaces/KeyframesFactory.md +0 -189
  29. package/docs/docs/reference/navigation.json +0 -64
  30. package/docs/docs/reference/type-aliases/CSSStyleSheetSource.md +0 -13
  31. package/docs/docs/reference/type-aliases/KeyframeArgument.md +0 -15
  32. package/docs/docs/reference/type-aliases/ParsedKeyframesRules.md +0 -22
  33. package/docs/docs/reference/variables/default.md +0 -12
  34. package/docs/package-lock.json +0 -2321
  35. package/docs/package.json +0 -22
  36. package/docs/typedoc/plugin-markdown-mdn-links-fix.js +0 -43
  37. package/docs/typedoc/plugin-markdown-see-also.js +0 -262
  38. package/docs/typedoc/plugin-param-names.js +0 -17
  39. package/docs/typedoc.config.js +0 -81
  40. package/docs/vercel.json +0 -14
  41. package/rollup.config.js +0 -42
  42. package/tsconfig.default.json +0 -44
  43. package/tsconfig.json +0 -10
@@ -1,147 +0,0 @@
1
-
2
- .monaco-editor .iPadShowKeyboard {
3
- display: none;
4
- }
5
-
6
-
7
- /* override vitepress theme style for '.vp-doc a' in monaco editor
8
- (it messes up the autocomplete styles) */
9
- .vp-doc .monaco-editor a {
10
- transition: unset;
11
- text-decoration: unset;
12
- text-underline-offset: unset;
13
- font-weight: unset;
14
- color: inherit;
15
- }
16
-
17
- .vp-doc .monaco-editor a:hover {
18
- color: inherit;
19
- }
20
-
21
- .vp-doc .monaco-editor :not(pre, h1, h2, h3, h4, h5, h6) > code {
22
- font-size: unset;
23
- color: inherit;
24
- }
25
-
26
- .vp-doc .monaco-editor li+li {
27
- margin-top: 0;
28
- }
29
-
30
-
31
- .vp-doc h5, .vp-doc h6 {
32
- margin: 16px 0;
33
- }
34
-
35
- .vp-doc h6 {
36
- color: var(--vp-c-text-2);
37
- }
38
-
39
-
40
- .VPLocalSearchBox {
41
-
42
- .shell {
43
- padding: 0 !important;
44
- gap: 12px !important;
45
- }
46
-
47
- .search-bar {
48
- padding: 7px 12px !important;
49
- font-size: 25px;
50
- border: none !important;
51
- border-bottom: 1px solid var(--vp-c-divider) !important;
52
- border-radius: 0 !important;
53
- }
54
-
55
- .search-bar .local-search-icon {
56
- font-size: 23px;
57
- background-color: var(--vp-c-text-2);
58
- }
59
-
60
- .search-bar .search-input {
61
- font-family: inherit;
62
- padding-left: 3px;
63
-
64
- &::placeholder {
65
- color: var(--vp-c-text-3);
66
- }
67
- }
68
-
69
- .search-bar .search-actions .clear-button:disabled {
70
- display: none;
71
- }
72
-
73
- /* .search-bar:has(+ .results:empty) .search-actions .toggle-layout-button,
74
- .search-bar .search-actions:has(.clear-button:disabled) .toggle-layout-button { */
75
- /* .search-bar .search-actions .toggle-layout-button {
76
- display: none;
77
- } */
78
-
79
- .results {
80
- padding: 12px;
81
- padding-top: 0;
82
- scroll-padding-bottom: 12px;
83
- }
84
-
85
- .results .result {
86
- border: solid 2px transparent !important;
87
-
88
- &.selected {
89
- background-color: var(--vp-c-brand-soft);
90
- }
91
- }
92
-
93
- .results .result .excerpt-wrapper {
94
- mask-image: linear-gradient(transparent 0%, #000 8px, #000 calc(100% - 8px), transparent 100%);
95
-
96
- .excerpt-gradient-bottom, .excerpt-gradient-top {
97
- display: none;
98
- }
99
- }
100
-
101
- .results .result .excerpt {
102
- .vp-doc div[class*='language-'], .vp-block {
103
- border-radius: 8px;
104
- margin: 16px 0;
105
- }
106
- }
107
-
108
- &:has(
109
- .results:empty,
110
- .search-bar .search-actions .clear-button:disabled
111
- ) {
112
- .results {
113
- display: none;
114
- }
115
- .search-bar {
116
- border-bottom: none !important;
117
- }
118
- }
119
-
120
- .search-keyboard-shortcuts {
121
- display: none !important;
122
- }
123
-
124
- }
125
-
126
-
127
- @media (min-width: 768px) {
128
-
129
- .VPNavBarSearchButton {
130
-
131
- height: 38px !important;
132
- /* width: 127px; */
133
- width: 140px;
134
- /* justify-content: center; */
135
-
136
- .keys {
137
- display: none;
138
- }
139
-
140
- }
141
-
142
- }
143
-
144
-
145
- :root {
146
- -webkit-tap-highlight-color: transparent;
147
- }
@@ -1,5 +0,0 @@
1
- declare module '*.vue' {
2
- import type { DefineComponent } from 'vue'
3
- const component: DefineComponent<{}, {}, any>
4
- export default component
5
- }
@@ -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,131 +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
- ```js [CDN]
15
- /* Import the module directly: */
16
- import KeyframeKit from 'https://unpkg.com/keyframekit'
17
- ```
18
- :::
19
-
20
- ## Usage
21
-
22
- ### Playing CSS-defined animations with JS
23
-
24
- In your CSS:
25
- ```css
26
- @keyframes rotate-small { ... }
27
- ```
28
-
29
- Then, in JS:
30
- ```js
31
- import KeyframeKit from 'keyframekit';
32
-
33
- const documentStyleSheets = await KeyframeKit.getDocumentStyleSheetsOnLoad();
34
-
35
- // get animation keyframes from the document's stylesheets
36
- const rotateSmallAnimKeyframes = KeyframeKit.getStyleSheetKeyframes({
37
- of: 'rotate-small',
38
- in: documentStyleSheets
39
- });
40
-
41
- // then, define your animation
42
- const rotateSmallAnim = rotateSmallAnimKeyframes.toKeyframeEffect({
43
- duration: 700,
44
- easing: 'ease'
45
- });
46
-
47
- // finally, attach it to an element:
48
- const attachedAnim = rotateSmallAnim.toAnimation({
49
- target: document.querySelector('.el')
50
- });
51
-
52
- attachedAnim.play();
53
- ```
54
-
55
- The primary reason to play your animation with JS is because you get way more control over its playback:
56
- ```js
57
- attachedAnim.pause();
58
- attachedAnim.playbackRate = -1;
59
- const progress = attachedAnim.overallProgress; // 0 to 1 (Baseline newly available)
60
- await attachedAnim.finished;
61
- ```
62
- [...and more.][3]
63
-
64
- ### Importing animations directly from a CSS file
65
-
66
- Instead of getting an animation from the document's stylesheets, you can also import it directly from a CSS file.
67
-
68
- ```js
69
- import KeyframeKit from 'keyframekit';
70
-
71
- const styleSheet = await KeyframeKit.importStyleSheet('./styles.css');
72
-
73
- // get animation keyframes from stylesheet
74
- const rotateSmallAnimKeyframes = KeyframeKit.getStyleSheetKeyframes({
75
- of: 'rotate-small',
76
- in: styleSheet
77
- });
78
- ```
79
-
80
- > Note: This won't resolve any `@import` rules in the stylesheet. [See more.][4]
81
-
82
- ### Defining animations in JS
83
-
84
- The [`KeyframeEffectParameters`](reference/classes/KeyframeEffectParameters.md) class provides a more convenient way to define your animations in JS than is offered natively.
85
- It's useful for when you want to have all your animation code in one place.
86
-
87
- ```js
88
- import { KeyframeEffectParameters } from 'keyframekit';
89
-
90
- // define your animation
91
- const linkTextHoverAnim = new KeyframeEffectParameters({
92
-
93
- keyframes: {
94
- // 0 to 1. equivalent to CSS keyframe percentage values:
95
- offset: [0, 0.499, 0.5, 1],
96
- // respective CSS property keyframes:
97
- clipPath: ['inset(0 0 0 0)', 'inset(100% 0 0 0)', 'inset(0 0 100% 0)', 'inset(0 0 0 0)'],
98
- top: ['0', '-20px', '20px', '0']
99
- },
100
-
101
- options: {
102
- duration: 700,
103
- easing: 'ease'
104
- }
105
-
106
- });
107
-
108
- // then, attach it to an element:
109
- const attachedAnim = linkTextHoverAnim.toAnimation({
110
- target: document.querySelector('.link')
111
- });
112
-
113
- attachedAnim.play();
114
- ```
115
-
116
- ### Full reference
117
- [See here.](/reference/index.md)
118
-
119
- ## Typing
120
-
121
- This library is fully compatable with native JS, but it also has full spec-compliant type support, including declaration files and source maps.
122
-
123
- ## License
124
-
125
- [MIT](https://github.com/benhatsor/KeyframeKit/blob/main/LICENSE)
126
-
127
-
128
- [1]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Animations_API
129
- [2]: https://benhatsor.medium.com/99573ef4738b
130
- [3]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Animations_API/Using_the_Web_Animations_API
131
- [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
- /** Thrown if keyframes rule name is not 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
- /** Thrown if source is not 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
- /** Thrown if 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,qDAAqD;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAIrD,uEAAuE;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAIvE,sDAAsD;;;;;;;;;;;;;;;;MAI7C;IAGX;;;;;OAKG;IACG,4BAA4B,CAAC,EAAE,QAA0B,EAAE,GAAE;QACjE,QAAQ,CAAC,EAAE,QAAQ,CAAA;KACf;IAWN;;;;;;OAMG;IACG,gBAAgB,CAAC,GAAG,EAAE,MAAM;IAwBlC;;;;;;OAMG;IACH,sBAAsB,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE;QACnD,EAAE,EAAE,MAAM,CAAC;QACX,EAAE,EAAE,mBAAmB,CAAA;KACxB,GAAG,eAAe,GAAG,SAAS;IA0E/B;;;;;OAKG;IACH,8BAA8B,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE;QAC7C,EAAE,EAAE,mBAAmB,CAAA;KACxB,GAAG,oBAAoB;IAsExB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE;QACtC,IAAI,EAAE,gBAAgB,CAAA;KACvB,GAAG,eAAe;CAoHpB;;AAED,wBAAsC;AACtC,YAAY,EAAE,gBAAgB,EAAE,CAAC;AAGjC,iFAAiF;AACjF,MAAM,MAAM,gBAAgB,GAAG,QAAQ,EAAE,GAAG,wBAAwB,CAAC;AAErE,8EAA8E;AAC9E,qBAAa,wBAAwB;;IAEnC,SAAS,EAAE,gBAAgB,CAAC;IAC5B,OAAO,EAAE,qBAAqB,CAAC;IAE/B;;;;OAIG;gBACS,EAAE,SAAS,EAAE,OAAY,EAAE,EAAE;QACvC,SAAS,EAAE,gBAAgB,CAAC;QAC5B,OAAO,CAAC,EAAE,MAAM,GAAG,qBAAqB,CAAA;KACzC;IAKD;;;;;;;;;;OAUG;IACH,WAAW,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAsB,EAAE,QAA4B,EAAE,EAAE;QACrF,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;QACvB,OAAO,CAAC,EAAE,MAAM,GAAG,qBAAqB,CAAC;QACzC,QAAQ,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAA;KACpC,GAAG,SAAS;CAqCd;AAGD,qBAAa,eAAe;IAE1B,SAAS,EAAE,QAAQ,EAAE,CAAC;gBAEV,SAAS,EAAE,QAAQ,EAAE;IAIjC;;;OAGG;IACH,gBAAgB,CACd,OAAO,EAAE,MAAM,GAAG,qBAAqB,GAAG,IAAI,GAC7C,wBAAwB;CAwB5B;AAGD,MAAM,MAAM,oBAAoB,GAAG;IACjC,CAAC,QAAQ,EAAE,MAAM,GAAG,eAAe,CAAA;CACpC,CAAC"}