@motionone/generators
Advanced tools
Comparing version 10.13.2 to 10.14.0
@@ -5,12 +5,14 @@ 'use strict'; | ||
var utils = require('@motionone/utils'); | ||
const timeStep = 10; | ||
const maxDuration = 10000; | ||
function pregenerateKeyframes(generator) { | ||
function pregenerateKeyframes(generator, toUnit = utils.noopReturn) { | ||
let overshootDuration = undefined; | ||
let timestamp = timeStep; | ||
let state = generator(0); | ||
const keyframes = [state.current]; | ||
const keyframes = [toUnit(state.current)]; | ||
while (!state.done && timestamp < maxDuration) { | ||
state = generator(timestamp); | ||
keyframes.push(state.done ? state.target : state.current); | ||
keyframes.push(toUnit(state.done ? state.target : state.current)); | ||
if (overshootDuration === undefined && state.hasReachedTarget) { | ||
@@ -17,0 +19,0 @@ overshootDuration = timestamp; |
@@ -0,11 +1,13 @@ | ||
import { noopReturn } from '@motionone/utils'; | ||
const timeStep = 10; | ||
const maxDuration = 10000; | ||
function pregenerateKeyframes(generator) { | ||
function pregenerateKeyframes(generator, toUnit = noopReturn) { | ||
let overshootDuration = undefined; | ||
let timestamp = timeStep; | ||
let state = generator(0); | ||
const keyframes = [state.current]; | ||
const keyframes = [toUnit(state.current)]; | ||
while (!state.done && timestamp < maxDuration) { | ||
state = generator(timestamp); | ||
keyframes.push(state.done ? state.target : state.current); | ||
keyframes.push(toUnit(state.done ? state.target : state.current)); | ||
if (overshootDuration === undefined && state.hasReachedTarget) { | ||
@@ -12,0 +14,0 @@ overshootDuration = timestamp; |
@@ -0,11 +1,12 @@ | ||
import { noopReturn } from "@motionone/utils"; | ||
const timeStep = 10; | ||
const maxDuration = 10000; | ||
export function pregenerateKeyframes(generator) { | ||
export function pregenerateKeyframes(generator, toUnit = noopReturn) { | ||
let overshootDuration = undefined; | ||
let timestamp = timeStep; | ||
let state = generator(0); | ||
const keyframes = [state.current]; | ||
const keyframes = [toUnit(state.current)]; | ||
while (!state.done && timestamp < maxDuration) { | ||
state = generator(timestamp); | ||
keyframes.push(state.done ? state.target : state.current); | ||
keyframes.push(toUnit(state.done ? state.target : state.current)); | ||
if (overshootDuration === undefined && state.hasReachedTarget) { | ||
@@ -12,0 +13,0 @@ overshootDuration = timestamp; |
{ | ||
"name": "@motionone/generators", | ||
"version": "10.13.2", | ||
"version": "10.14.0", | ||
"description": "A collection of animation generators.", | ||
@@ -18,4 +18,4 @@ "license": "MIT", | ||
"dependencies": { | ||
"@motionone/types": "^10.13.2", | ||
"@motionone/utils": "^10.13.2", | ||
"@motionone/types": "^10.14.0", | ||
"@motionone/utils": "^10.14.0", | ||
"tslib": "^2.3.1" | ||
@@ -33,3 +33,3 @@ }, | ||
], | ||
"gitHead": "a33ab88400c8aac4a6755cda6f93c24563d9ddc5" | ||
"gitHead": "4c59ce9e5539899722427bd00f857dc80f29fc09" | ||
} |
import { AnimationGenerator } from "@motionone/types"; | ||
export interface KeyframesMetadata { | ||
keyframes: number[]; | ||
keyframes: Array<string | number>; | ||
duration: number; | ||
overshootDuration: number; | ||
} | ||
export declare function pregenerateKeyframes(generator: AnimationGenerator): KeyframesMetadata; | ||
export declare function pregenerateKeyframes(generator: AnimationGenerator, toUnit?: (value: number) => number | string): KeyframesMetadata; | ||
//# sourceMappingURL=pregenerate-keyframes.d.ts.map |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42402
654
Updated@motionone/types@^10.14.0
Updated@motionone/utils@^10.14.0