Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | 3x 47x 5x 42x 14x 28x 28x 14x 14x 13x 1x | import { spring } from "../generators/spring" import { keyframes } from "../generators/keyframes" import { decay } from "../generators/decay" /** * These are the default types of animation included with animate. * TODO: Consider removing decay */ const types = { keyframes, spring, decay } interface Options { to?: any type?: "decay" | "keyframes" | "spring" } export function detectAnimationFromOptions<T extends Options>(config: T) { if (Array.isArray(config.to)) { /** * If to is defined as a keyframes array we want to force this to be a keyframes * animation. In the future it might be possible to allow spring keyframes. */ return keyframes } else if (types[config.type]) { /** * Or if the user has explicity defined their own animation type, return that. */ return types[config.type] } /** * Attempt to detect which animation to use based on the options provided */ const keys = new Set(Object.keys(config)) if ( keys.has("ease") || (keys.has("duration") && !keys.has("dampingRatio")) ) { return keyframes } else if ( keys.has("dampingRatio") || keys.has("stiffness") || keys.has("mass") || keys.has("damping") || keys.has("restSpeed") || keys.has("restDelta") ) { return spring } return keyframes } |