2021-12-08 22:43:31 +01:00
|
|
|
import KEC from '../objects/kute';
|
|
|
|
import units from '../interpolation/units';
|
2021-03-30 11:23:29 +02:00
|
|
|
|
|
|
|
// Component Properties
|
|
|
|
const textProperties = ['fontSize', 'lineHeight', 'letterSpacing', 'wordSpacing'];
|
|
|
|
const textOnStart = {};
|
|
|
|
|
2021-12-08 22:43:31 +01:00
|
|
|
/**
|
|
|
|
* Sets the property update function.
|
|
|
|
* @param {string} tweenProp the property name
|
|
|
|
*/
|
2021-03-30 11:23:29 +02:00
|
|
|
export function textPropOnStart(tweenProp) {
|
2021-12-08 22:43:31 +01:00
|
|
|
if (this.valuesEnd[tweenProp] && !KEC[tweenProp]) {
|
|
|
|
KEC[tweenProp] = (elem, a, b, v) => {
|
|
|
|
// eslint-disable-next-line no-param-reassign -- impossible to satisfy
|
2021-03-30 11:23:29 +02:00
|
|
|
elem.style[tweenProp] = units(a.v, b.v, b.u, v);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
textProperties.forEach((tweenProp) => {
|
|
|
|
textOnStart[tweenProp] = textPropOnStart;
|
|
|
|
});
|
|
|
|
|
|
|
|
// Component Base
|
2021-12-08 22:43:31 +01:00
|
|
|
const TextPropertiesBase = {
|
2021-03-30 11:23:29 +02:00
|
|
|
component: 'baseTextProperties',
|
|
|
|
category: 'textProps',
|
|
|
|
// properties: textProperties,
|
|
|
|
// defaultValues: {fontSize:0,lineHeight:0,letterSpacing:0,wordSpacing:0},
|
|
|
|
Interpolate: { units },
|
|
|
|
functions: { onStart: textOnStart },
|
|
|
|
};
|
|
|
|
|
2021-12-08 22:43:31 +01:00
|
|
|
export default TextPropertiesBase;
|