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
46 lines
1.2 KiB
JavaScript
46 lines
1.2 KiB
JavaScript
import KEC from '../objects/kute';
|
|
import numbers from '../interpolation/numbers';
|
|
import colors from '../interpolation/colors';
|
|
|
|
// Component Interpolation
|
|
// rgba1, rgba2, progress
|
|
|
|
// Component Properties
|
|
// supported formats
|
|
// 'hex', 'rgb', 'rgba' '#fff' 'rgb(0,0,0)' / 'rgba(0,0,0,0)' 'red' (IE9+)
|
|
const supportedColors = [
|
|
'color', 'backgroundColor', 'outlineColor',
|
|
'borderColor',
|
|
'borderTopColor', 'borderRightColor',
|
|
'borderBottomColor', 'borderLeftColor',
|
|
];
|
|
|
|
// Component Functions
|
|
/**
|
|
* Sets the property update function.
|
|
* @param {string} tweenProp the property name
|
|
*/
|
|
export function onStartColors(tweenProp) {
|
|
if (this.valuesEnd[tweenProp] && !KEC[tweenProp]) {
|
|
KEC[tweenProp] = (elem, a, b, v) => {
|
|
// eslint-disable-next-line no-param-reassign
|
|
elem.style[tweenProp] = colors(a, b, v);
|
|
};
|
|
}
|
|
}
|
|
|
|
const colorsOnStart = {};
|
|
supportedColors.forEach((x) => { colorsOnStart[x] = onStartColors; });
|
|
|
|
// Component Base
|
|
export const baseColors = {
|
|
component: 'baseColors',
|
|
category: 'colors',
|
|
// properties: supportedColors,
|
|
// defaultValues: defaultColors,
|
|
Interpolate: { numbers, colors },
|
|
functions: { onStart: colorsOnStart },
|
|
};
|
|
|
|
export default baseColors;
|