2a5bac2bb3
* major JSDoc write up * removed ESLint `no-bitwise` exception, it only applies to specific functions and not the entire code * the `SVGCubicMorph` component will remove un-necessary `Z` path commands when is the case for better out of the box animation * fixed a minor disambiguation with `filterEffects` and `drop-shadow` property and its `dropshadow` interpolation function * TypeScript strong: all files are modules, easy to implement in any third party app * updated `CubicBezier` and SVGPathCommander * code cleanup
54 lines
2 KiB
JavaScript
54 lines
2 KiB
JavaScript
import prepareProperty from '../objects/prepareProperty';
|
|
import supportedProperties from '../objects/supportedProperties';
|
|
import defaultValues from '../objects/defaultValues';
|
|
|
|
/**
|
|
* prepareObject
|
|
*
|
|
* Returns all processed valuesStart / valuesEnd.
|
|
*
|
|
* @param {Element} obj the values start/end object
|
|
* @param {string} fn toggles between the two
|
|
*/
|
|
export default function prepareObject(obj, fn) { // this, props object, type: start/end
|
|
const propertiesObject = fn === 'start' ? this.valuesStart : this.valuesEnd;
|
|
|
|
Object.keys(prepareProperty).forEach((component) => {
|
|
const prepareComponent = prepareProperty[component];
|
|
const supportComponent = supportedProperties[component];
|
|
|
|
Object.keys(prepareComponent).forEach((tweenCategory) => {
|
|
const transformObject = {};
|
|
|
|
Object.keys(obj).forEach((tweenProp) => {
|
|
// scroll, opacity, other components
|
|
if (defaultValues[tweenProp] && prepareComponent[tweenProp]) {
|
|
propertiesObject[tweenProp] = prepareComponent[tweenProp]
|
|
.call(this, tweenProp, obj[tweenProp]);
|
|
|
|
// transform
|
|
} else if (!defaultValues[tweenCategory] && tweenCategory === 'transform'
|
|
&& supportComponent.includes(tweenProp)) {
|
|
transformObject[tweenProp] = obj[tweenProp];
|
|
|
|
// allow transformFunctions to work with preprocessed input values
|
|
} else if (!defaultValues[tweenProp] && tweenProp === 'transform') {
|
|
propertiesObject[tweenProp] = obj[tweenProp];
|
|
|
|
// colors, boxModel, category
|
|
} else if (!defaultValues[tweenCategory]
|
|
&& supportComponent && supportComponent.includes(tweenProp)) {
|
|
propertiesObject[tweenProp] = prepareComponent[tweenCategory]
|
|
.call(this, tweenProp, obj[tweenProp]);
|
|
}
|
|
});
|
|
|
|
// we filter out older browsers by checking Object.keys
|
|
if (Object.keys(transformObject).length) {
|
|
propertiesObject[tweenCategory] = prepareComponent[tweenCategory]
|
|
.call(this, tweenCategory, transformObject);
|
|
}
|
|
});
|
|
});
|
|
}
|