diff --git a/README.md b/README.md index 7d8b76e..6176b12 100644 --- a/README.md +++ b/README.md @@ -75,15 +75,6 @@ Parameters: Supports various numeric types: `number`, `Float64Array`, `Float32Array`, `Uint32Array`, `Int32Array`, `Uint16Array`, `Int16Array`, `Uint8Array`, `Int8Array`, `Array`. -## Types - -Extra types provided for TypeScript: - -- `Motion`: Represents an animatable value with methods: - - `update()`: Updates the motion state. - - `complete()`: Checks if the motion is complete. - - `interpolate(t: number)`: Interpolates the motion value at a given time t. - ## Cancelling Animations You can cancel ongoing animations using an `AbortSignal`: diff --git a/modules/spring.js b/modules/spring.js index 2945e73..0783c5c 100644 --- a/modules/spring.js +++ b/modules/spring.js @@ -37,6 +37,9 @@ function singlespring(current, destination, damping, stiffness, precision) { velocity = tuple[1]; } }, + destination(v) { + destination = v; + }, complete() { if (velocity !== 0 || current !== destination) return false; return true; @@ -68,6 +71,9 @@ function multispring(current, destination, damping, stiffness, precision) { } } }, + destination(v) { + destination = v; + }, complete() { for (let i = 0; i < current.length; i++) { if (velocity[i] !== 0 || current[i] !== destination[i]) return false; diff --git a/oscillation.d.ts b/oscillation.d.ts index f39046a..e71767a 100644 --- a/oscillation.d.ts +++ b/oscillation.d.ts @@ -50,6 +50,7 @@ export function motion, ...Motion[]]>( export type Motion = { update(n: number): void; + destination(v: Value): void; complete(): boolean; interpolate(t: number): Value; }; diff --git a/package.json b/package.json index 6d6edd0..4f7ac2c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "oscillation", "description": "An animation library", - "version": "0.4.0", + "version": "0.4.1", "license": "ISC", "author": "Oleksii Raspopov", "repository": "UnknownPrinciple/oscillation",