2021-12-08 22:43:31 +01:00
|
|
|
import defaultValues from '../objects/defaultValues';
|
|
|
|
import getStyleForProperty from '../process/getStyleForProperty';
|
|
|
|
import trueDimension from '../util/trueDimension';
|
|
|
|
import units from '../interpolation/units';
|
|
|
|
import { textPropOnStart } from './textPropertiesBase';
|
2021-03-30 11:23:29 +02:00
|
|
|
|
|
|
|
// Component Properties
|
|
|
|
const textProps = ['fontSize', 'lineHeight', 'letterSpacing', 'wordSpacing'];
|
|
|
|
const textOnStart = {};
|
|
|
|
|
|
|
|
// Component Functions
|
|
|
|
textProps.forEach((tweenProp) => {
|
|
|
|
textOnStart[tweenProp] = textPropOnStart;
|
|
|
|
});
|
|
|
|
|
2021-12-08 22:43:31 +01:00
|
|
|
/**
|
|
|
|
* Returns the current property computed style.
|
|
|
|
* @param {string} prop the property name
|
|
|
|
* @returns {string} computed style for property
|
|
|
|
*/
|
2021-03-30 11:23:29 +02:00
|
|
|
export function getTextProp(prop/* , value */) {
|
|
|
|
return getStyleForProperty(this.element, prop) || defaultValues[prop];
|
|
|
|
}
|
|
|
|
|
2021-12-08 22:43:31 +01:00
|
|
|
/**
|
|
|
|
* Returns the property tween object.
|
|
|
|
* @param {string} _ the property name
|
|
|
|
* @param {string} value the property value
|
|
|
|
* @returns {number} the property tween object
|
|
|
|
*/
|
|
|
|
export function prepareTextProp(/* prop */_, value) {
|
2021-03-30 11:23:29 +02:00
|
|
|
return trueDimension(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
// All Component Functions
|
|
|
|
const textPropFunctions = {
|
|
|
|
prepareStart: getTextProp,
|
|
|
|
prepareProperty: prepareTextProp,
|
|
|
|
onStart: textOnStart,
|
|
|
|
};
|
|
|
|
|
|
|
|
// Component Full
|
2021-12-08 22:43:31 +01:00
|
|
|
const TextProperties = {
|
2021-03-30 11:23:29 +02:00
|
|
|
component: 'textProperties',
|
|
|
|
category: 'textProperties',
|
|
|
|
properties: textProps,
|
|
|
|
defaultValues: {
|
|
|
|
fontSize: 0, lineHeight: 0, letterSpacing: 0, wordSpacing: 0,
|
|
|
|
},
|
|
|
|
Interpolate: { units },
|
|
|
|
functions: textPropFunctions,
|
|
|
|
Util: { trueDimension },
|
|
|
|
};
|
|
|
|
|
2021-12-08 22:43:31 +01:00
|
|
|
export default TextProperties;
|