Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// If it isn't a keyframes or the first keyframes value was set as `null`, read the
// value from the DOM. It might be worth investigating whether to check props (for SVG)
// or props.style (for HTML) if the value exists there before attempting to read.
if (value === null) {
value = this.readValueFromSource(key)
invariant(
value !== null,
`No initial value for "${key}" can be inferred. Ensure an initial value for "${key}" is defined on the component.`
)
}
if (typeof value === "string" && isNumericalString(value)) {
// If this is a number read as a string, ie "0" or "200", convert it to a number
value = parseFloat(value)
} else if (!getValueType(value) && complex.test(targetValue)) {
// If value is not recognised as animatable, ie "none", create an animatable version origin based on the target
value = complex.getAnimatableNone(targetValue as string)
}
this.values.set(key, motionValue(value))
this.baseTarget[key] = value
}
}
const getActionCreator = (prop: any) => {
// Pattern matching would be quite lovely here
if (typeof prop === 'number') {
return createAction;
} else if (Array.isArray(prop)) {
return createArrayAction;
} else if (isUnitProp(prop)) {
return createUnitAction;
} else if (color.test(prop)) {
return createColorAction;
} else if (complex.test(prop)) {
return createComplexAction;
} else if (typeof prop === 'object') {
return createObjectAction;
} else {
return createAction;
}
};
const isAnimatable = (value: string | number) => typeof value === "number" || complex.test(value)