Skip to content

Commit 46f3c30

Browse files
chore(gh-bot): 🚀 build types, api & library files
1 parent 517d07e commit 46f3c30

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+660
-179
lines changed

@types/index.d.ts

+22-21
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { TypeInterpolationFunction } from "./utils";
12
export * from "./utils";
23
/**
34
* The format to use when defining custom frame functions
@@ -190,6 +191,25 @@ export declare function interpolateComplex(frames: number[], values: (string | n
190191
* `[SpringFrame, mass, stiffness, damping, velocity]`
191192
*/
192193
export declare type TypeArrayFrameFunctionFormat = [TypeFrameFunction, ...number[]];
194+
/**
195+
* The list of spring easing functions
196+
*/
197+
export declare let EasingFunctions: {
198+
spring: TypeFrameFunction;
199+
"spring-in": TypeFrameFunction;
200+
"spring-out": TypeFrameFunction;
201+
"spring-in-out": TypeFrameFunction;
202+
"spring-out-in": TypeFrameFunction;
203+
};
204+
export declare let EasingFunctionKeys: string[];
205+
/**
206+
* Allows you to register new easing functions
207+
*/
208+
export declare function registerEasingFunction<T extends string>(key: T, fn?: TypeFrameFunction): void;
209+
/**
210+
* Allows you to register multiple new easing functions
211+
*/
212+
export declare function registerEasingFunctions<T extends Record<string, TypeFrameFunction>>(obj: T): void;
193213
/**
194214
* The formats supported for easings,
195215
* @example
@@ -200,7 +220,7 @@ export declare type TypeArrayFrameFunctionFormat = [TypeFrameFunction, ...number
200220
* * `"spring-out-in(mass, stiffness, damping, velocity)"`
201221
* `[SpringFrame, mass, stiffness, damping, velocity]`
202222
*/
203-
export declare type TypeEasings = `${keyof typeof EasingFunctions}` | `${keyof typeof EasingFunctions}(${string})` | TypeArrayFrameFunctionFormat;
223+
export declare type TypeEasings = `${keyof typeof EasingFunctions}` | `${keyof typeof EasingFunctions}(${string})` | (string & {}) | TypeArrayFrameFunctionFormat;
204224
/**
205225
* Spring Easing has 3 properties they are `easing` (all spring frame functions are supported), `numPoints` (the size of the Array the frmae function should create), and `decimal` (the number of decimal places of the values within said Array).
206226
*
@@ -236,25 +256,6 @@ export declare type TypeEasingOptions = {
236256
numPoints?: number;
237257
decimal?: number;
238258
};
239-
/**
240-
* The list of spring easing functions
241-
*/
242-
export declare const EasingFunctions: {
243-
spring: TypeFrameFunction;
244-
"spring-in": TypeFrameFunction;
245-
"spring-out": TypeFrameFunction;
246-
"spring-in-out": TypeFrameFunction;
247-
"spring-out-in": TypeFrameFunction;
248-
};
249-
export declare let EasingFunctionKeys: string[];
250-
/**
251-
* Allows you to register new easing functions
252-
*/
253-
export declare function registerEasingFunction(key: string, fn?: TypeFrameFunction): void;
254-
/**
255-
* Allows you to register multiple new easing functions
256-
*/
257-
export declare function registerEasingFunctions(...obj: Array<Record<string, any>>): void;
258259
/**
259260
* Convert easing parameters to Array of numbers, e.g. "spring(2, 500)" to [2, 500]
260261
*
@@ -374,5 +375,5 @@ export declare function GenerateSpringFrames(options?: TypeEasingOptions): [numb
374375
* ]
375376
* ```
376377
*/
377-
export declare function SpringEasing(values: (string | number)[], options?: TypeEasingOptions | TypeEasingOptions["easing"], customInterpolate?: (frames: number[], values: any[], decimal?: number) => string | number | any): [(string | number | any)[], number];
378+
export declare function SpringEasing(values: (string | number)[], options?: TypeEasingOptions | TypeEasingOptions["easing"], customInterpolate?: TypeInterpolationFunction): [(string | number | any)[], number];
378379
export default SpringEasing;

@types/utils.d.ts

+43
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,46 @@ export declare function toFixed(value: number, decimal: number): number;
3333
* @source Source code of `getUnit`
3434
*/
3535
export declare function getUnit(str: string | number): string;
36+
/**
37+
* The type for interpolation functions which at an instant in the animation, generate the corresponding interpolated frame
38+
*/
39+
export declare type TypeInstantaneousInterpolationFunction = (t: number, values: any[], decimal?: number) => string | number | any;
40+
/**
41+
* The type for interpolation functions which use an array of frames to generate the corresponding interpolated resulting frames
42+
*/
43+
export declare type TypeInterpolationFunction = (frames: number[], values: any[], decimal?: number) => (string | number | any)[];
44+
/**
45+
* Converts old interpolation syntax (the instantaneous interpolation function, e.g. `(t, values, decimal) => { ... }`)
46+
* to complete animation frames
47+
*
48+
* You use it like so,
49+
* ```ts
50+
* import { SpringEasing, toAnimationFrames, toFixed, scale, limit } from "spring-easing";
51+
*
52+
* function interpolateNumber(t: number, values: number[], decimal = 3) {
53+
* // nth index
54+
* const n = values.length - 1;
55+
*
56+
* // The current index given t
57+
* const i = limit(Math.floor(t * n), 0, n - 1);
58+
*
59+
* const start = values[i];
60+
* const end = values[i + 1];
61+
* const progress = (t - i / n) * n;
62+
*
63+
* return toFixed(scale(progress, start, end), decimal);
64+
* }
65+
*
66+
* function interpolatePixels(t: number, values: number[], decimal = 3) {
67+
* const result = interpolateNumber(t, values, decimal);
68+
* return `${result}px`;
69+
* }
70+
*
71+
* SpringEasing(
72+
* [0, 250],
73+
* 'spring',
74+
* toAnimationFrames(interpolatePixels)
75+
* );
76+
* ```
77+
*/
78+
export declare function toAnimationFrames(customInterpolate: TypeInstantaneousInterpolationFunction): TypeInterpolationFunction;

docs/assets/search.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/functions/EaseInOut.html

+4-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ <h5 id="frame-typeframefunction">frame: <a href="../types/TypeFrameFunction.html
3232
</div></li></ul></div>
3333
<h4 class="tsd-returns-title" id="returns-typeframefunction">Returns <a href="../types/TypeFrameFunction.html" class="tsd-signature-type" data-tsd-kind="Type alias">TypeFrameFunction</a></h4><aside class="tsd-sources">
3434
<ul>
35-
<li>Defined in <a href="https://github.com/okikio/spring-easing/blob/f6a5d68/src/index.ts#L179" target="_blank" rel="noopener">index.ts:179<span><span class="external-icon"><svg preserveAspectRatio="xMidYMid meet" width="1.2em" height="1.2em" viewBox="0 0 24 24"><path d="M10.75 3a.75.75 0 0 0 0 1.5h7.67L3.22 19.7a.764.764 0 1 0 1.081 1.081l15.2-15.2v7.669a.75.75 0 0 0 1.5 0v-9.5a.75.75 0 0 0-.75-.75h-9.5Z"></path></svg></span></span></a></li></ul></aside></li></ul></section></div>
35+
<li>Defined in <a href="https://github.com/okikio/spring-easing/blob/517d07e/src/index.ts#L180" target="_blank" rel="noopener">index.ts:180<span><span class="external-icon"><svg preserveAspectRatio="xMidYMid meet" width="1.2em" height="1.2em" viewBox="0 0 24 24"><path d="M10.75 3a.75.75 0 0 0 0 1.5h7.67L3.22 19.7a.764.764 0 1 0 1.081 1.081l15.2-15.2v7.669a.75.75 0 0 0 1.5 0v-9.5a.75.75 0 0 0-.75-.75h-9.5Z"></path></svg></span></span></a></li></ul></aside></li></ul></section></div>
3636
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
3737
<div class="tsd-navigation settings">
3838
<details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
@@ -61,6 +61,8 @@ <h3 id="-modules"><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><p
6161
<li class="tsd-kind-type-alias"><a href="../types/TypeEasingOptions.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-4194304-path"></use><use href="#icon-4194304-text"></use></svg>Type<wbr>Easing<wbr>Options</a></li>
6262
<li class="tsd-kind-type-alias"><a href="../types/TypeEasings.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-4194304-path"></use><use href="#icon-4194304-text"></use></svg>Type<wbr>Easings</a></li>
6363
<li class="tsd-kind-type-alias"><a href="../types/TypeFrameFunction.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-4194304-path"></use><use href="#icon-4194304-text"></use></svg>Type<wbr>Frame<wbr>Function</a></li>
64+
<li class="tsd-kind-type-alias"><a href="../types/TypeInstantaneousInterpolationFunction.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-4194304-path"></use><use href="#icon-4194304-text"></use></svg>Type<wbr>Instantaneous<wbr>Interpolation<wbr>Function</a></li>
65+
<li class="tsd-kind-type-alias"><a href="../types/TypeInterpolationFunction.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-4194304-path"></use><use href="#icon-4194304-text"></use></svg>Type<wbr>Interpolation<wbr>Function</a></li>
6466
<li class="tsd-kind-variable"><a href="../variables/EasingDurationCache.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-variable)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6" id="icon-32-path"></rect><path d="M11.106 16L8.85 7.24H9.966L11.454 13.192C11.558 13.608 11.646 13.996 11.718 14.356C11.79 14.708 11.842 14.976 11.874 15.16C11.906 14.976 11.954 14.708 12.018 14.356C12.09 13.996 12.178 13.608 12.282 13.192L13.758 7.24H14.85L12.582 16H11.106Z" fill="var(--color-text)" id="icon-32-text"></path></svg>Easing<wbr>Duration<wbr>Cache</a></li>
6567
<li class="tsd-kind-variable"><a href="../variables/EasingFunctionKeys.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-32-path"></use><use href="#icon-32-text"></use></svg>Easing<wbr>Function<wbr>Keys</a></li>
6668
<li class="tsd-kind-variable"><a href="../variables/EasingFunctions.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-32-path"></use><use href="#icon-32-text"></use></svg>Easing<wbr>Functions</a></li>
@@ -89,6 +91,7 @@ <h3 id="-modules"><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><p
8991
<li class="tsd-kind-function"><a href="registerEasingFunction.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-64-path"></use><use href="#icon-64-text"></use></svg>register<wbr>Easing<wbr>Function</a></li>
9092
<li class="tsd-kind-function"><a href="registerEasingFunctions.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-64-path"></use><use href="#icon-64-text"></use></svg>register<wbr>Easing<wbr>Functions</a></li>
9193
<li class="tsd-kind-function"><a href="scale.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-64-path"></use><use href="#icon-64-text"></use></svg>scale</a></li>
94+
<li class="tsd-kind-function"><a href="toAnimationFrames.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-64-path"></use><use href="#icon-64-text"></use></svg>to<wbr>Animation<wbr>Frames</a></li>
9295
<li class="tsd-kind-function"><a href="toFixed.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-64-path"></use><use href="#icon-64-text"></use></svg>to<wbr>Fixed</a></li></ul></nav></div></div>
9396
<div class="container tsd-generator">
9497
<p style="line-height: 28px;">Generated using <a href="https://typedoc.org/" target="_blank" rel="noopener">TypeDoc<span><span class="external-icon"><svg preserveAspectRatio="xMidYMid meet" width="1.2em" height="1.2em" viewBox="0 0 24 24"><path d="M10.75 3a.75.75 0 0 0 0 1.5h7.67L3.22 19.7a.764.764 0 1 0 1.081 1.081l15.2-15.2v7.669a.75.75 0 0 0 1.5 0v-9.5a.75.75 0 0 0-.75-.75h-9.5Z"></path></svg></span></span></a></p></div>

docs/functions/EaseOut.html

+4-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ <h5 id="frame-typeframefunction">frame: <a href="../types/TypeFrameFunction.html
3434
</div></li></ul></div>
3535
<h4 class="tsd-returns-title" id="returns-typeframefunction">Returns <a href="../types/TypeFrameFunction.html" class="tsd-signature-type" data-tsd-kind="Type alias">TypeFrameFunction</a></h4><aside class="tsd-sources">
3636
<ul>
37-
<li>Defined in <a href="https://github.com/okikio/spring-easing/blob/f6a5d68/src/index.ts#L166" target="_blank" rel="noopener">index.ts:166<span><span class="external-icon"><svg preserveAspectRatio="xMidYMid meet" width="1.2em" height="1.2em" viewBox="0 0 24 24"><path d="M10.75 3a.75.75 0 0 0 0 1.5h7.67L3.22 19.7a.764.764 0 1 0 1.081 1.081l15.2-15.2v7.669a.75.75 0 0 0 1.5 0v-9.5a.75.75 0 0 0-.75-.75h-9.5Z"></path></svg></span></span></a></li></ul></aside></li></ul></section></div>
37+
<li>Defined in <a href="https://github.com/okikio/spring-easing/blob/517d07e/src/index.ts#L167" target="_blank" rel="noopener">index.ts:167<span><span class="external-icon"><svg preserveAspectRatio="xMidYMid meet" width="1.2em" height="1.2em" viewBox="0 0 24 24"><path d="M10.75 3a.75.75 0 0 0 0 1.5h7.67L3.22 19.7a.764.764 0 1 0 1.081 1.081l15.2-15.2v7.669a.75.75 0 0 0 1.5 0v-9.5a.75.75 0 0 0-.75-.75h-9.5Z"></path></svg></span></span></a></li></ul></aside></li></ul></section></div>
3838
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
3939
<div class="tsd-navigation settings">
4040
<details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
@@ -63,6 +63,8 @@ <h3 id="-modules"><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><p
6363
<li class="tsd-kind-type-alias"><a href="../types/TypeEasingOptions.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-4194304-path"></use><use href="#icon-4194304-text"></use></svg>Type<wbr>Easing<wbr>Options</a></li>
6464
<li class="tsd-kind-type-alias"><a href="../types/TypeEasings.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-4194304-path"></use><use href="#icon-4194304-text"></use></svg>Type<wbr>Easings</a></li>
6565
<li class="tsd-kind-type-alias"><a href="../types/TypeFrameFunction.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-4194304-path"></use><use href="#icon-4194304-text"></use></svg>Type<wbr>Frame<wbr>Function</a></li>
66+
<li class="tsd-kind-type-alias"><a href="../types/TypeInstantaneousInterpolationFunction.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-4194304-path"></use><use href="#icon-4194304-text"></use></svg>Type<wbr>Instantaneous<wbr>Interpolation<wbr>Function</a></li>
67+
<li class="tsd-kind-type-alias"><a href="../types/TypeInterpolationFunction.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-4194304-path"></use><use href="#icon-4194304-text"></use></svg>Type<wbr>Interpolation<wbr>Function</a></li>
6668
<li class="tsd-kind-variable"><a href="../variables/EasingDurationCache.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-variable)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6" id="icon-32-path"></rect><path d="M11.106 16L8.85 7.24H9.966L11.454 13.192C11.558 13.608 11.646 13.996 11.718 14.356C11.79 14.708 11.842 14.976 11.874 15.16C11.906 14.976 11.954 14.708 12.018 14.356C12.09 13.996 12.178 13.608 12.282 13.192L13.758 7.24H14.85L12.582 16H11.106Z" fill="var(--color-text)" id="icon-32-text"></path></svg>Easing<wbr>Duration<wbr>Cache</a></li>
6769
<li class="tsd-kind-variable"><a href="../variables/EasingFunctionKeys.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-32-path"></use><use href="#icon-32-text"></use></svg>Easing<wbr>Function<wbr>Keys</a></li>
6870
<li class="tsd-kind-variable"><a href="../variables/EasingFunctions.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-32-path"></use><use href="#icon-32-text"></use></svg>Easing<wbr>Functions</a></li>
@@ -91,6 +93,7 @@ <h3 id="-modules"><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><p
9193
<li class="tsd-kind-function"><a href="registerEasingFunction.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-64-path"></use><use href="#icon-64-text"></use></svg>register<wbr>Easing<wbr>Function</a></li>
9294
<li class="tsd-kind-function"><a href="registerEasingFunctions.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-64-path"></use><use href="#icon-64-text"></use></svg>register<wbr>Easing<wbr>Functions</a></li>
9395
<li class="tsd-kind-function"><a href="scale.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-64-path"></use><use href="#icon-64-text"></use></svg>scale</a></li>
96+
<li class="tsd-kind-function"><a href="toAnimationFrames.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-64-path"></use><use href="#icon-64-text"></use></svg>to<wbr>Animation<wbr>Frames</a></li>
9497
<li class="tsd-kind-function"><a href="toFixed.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-64-path"></use><use href="#icon-64-text"></use></svg>to<wbr>Fixed</a></li></ul></nav></div></div>
9598
<div class="container tsd-generator">
9699
<p style="line-height: 28px;">Generated using <a href="https://typedoc.org/" target="_blank" rel="noopener">TypeDoc<span><span class="external-icon"><svg preserveAspectRatio="xMidYMid meet" width="1.2em" height="1.2em" viewBox="0 0 24 24"><path d="M10.75 3a.75.75 0 0 0 0 1.5h7.67L3.22 19.7a.764.764 0 1 0 1.081 1.081l15.2-15.2v7.669a.75.75 0 0 0 1.5 0v-9.5a.75.75 0 0 0-.75-.75h-9.5Z"></path></svg></span></span></a></p></div>

0 commit comments

Comments
 (0)