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
66 lines
1.7 KiB
JavaScript
66 lines
1.7 KiB
JavaScript
import defaultValues from '../objects/defaultValues';
|
|
import getStyleForProperty from '../process/getStyleForProperty';
|
|
import trueColor from '../util/trueColor';
|
|
import numbers from '../interpolation/numbers';
|
|
import colors from '../interpolation/colors';
|
|
import { onStartColors } from './colorPropertiesBase';
|
|
|
|
// 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',
|
|
];
|
|
|
|
const defaultColors = {};
|
|
supportedColors.forEach((tweenProp) => {
|
|
defaultColors[tweenProp] = '#000';
|
|
});
|
|
|
|
// Component Functions
|
|
const colorsOnStart = {};
|
|
supportedColors.forEach((x) => {
|
|
colorsOnStart[x] = onStartColors;
|
|
});
|
|
|
|
/**
|
|
* Returns the current property computed style.
|
|
* @param {string} prop the property name
|
|
* @returns {string} property computed style
|
|
*/
|
|
function getColor(prop/* , value */) {
|
|
return getStyleForProperty(this.element, prop) || defaultValues[prop];
|
|
}
|
|
|
|
/**
|
|
* Returns the property tween object.
|
|
* @param {string} _ the property name
|
|
* @param {string} value the property value
|
|
* @returns {KUTE.colorObject} the property tween object
|
|
*/
|
|
function prepareColor(/* prop, */_, value) {
|
|
return trueColor(value);
|
|
}
|
|
|
|
// All Component Functions
|
|
const colorFunctions = {
|
|
prepareStart: getColor,
|
|
prepareProperty: prepareColor,
|
|
onStart: colorsOnStart,
|
|
};
|
|
|
|
// Component Full
|
|
const colorProperties = {
|
|
component: 'colorProperties',
|
|
category: 'colors',
|
|
properties: supportedColors,
|
|
defaultValues: defaultColors,
|
|
Interpolate: { numbers, colors },
|
|
functions: colorFunctions,
|
|
Util: { trueColor },
|
|
};
|
|
|
|
export default colorProperties;
|