kute.js/src/components/textProperties.js

46 lines
1.4 KiB
JavaScript
Raw Normal View History

import defaultValues from '../objects/defaultValues.js'
2020-06-12 10:04:59 +02:00
import Components from '../objects/components.js'
import getStyleForProperty from '../process/getStyleForProperty.js'
import trueDimension from '../util/trueDimension.js'
2020-06-20 11:23:25 +02:00
import units from '../interpolation/units.js'
import {textPropOnStart} from './textPropertiesBase.js'
2020-06-09 22:06:26 +02:00
// const textProperties = { category : 'textProperties', defaultValues: [], interpolators: {units} }, functions = { prepareStart, prepareProperty, onStart:{} }
2020-06-09 22:06:26 +02:00
// Component Properties
const textProps = ['fontSize','lineHeight','letterSpacing','wordSpacing']
2020-06-09 22:06:26 +02:00
const textOnStart = {}
// Component Functions
textProps.forEach(tweenProp => {
2020-06-09 22:06:26 +02:00
textOnStart[tweenProp] = textPropOnStart
})
export function getTextProp(prop) {
return getStyleForProperty(this.element,prop) || defaultValues[prop];
}
export function prepareTextProp(prop,value) {
return trueDimension(value);
}
// All Component Functions
const textPropFunctions = {
prepareStart: getTextProp,
prepareProperty: prepareTextProp,
onStart: textOnStart
}
// Component Full
const textProperties = {
2020-06-09 22:06:26 +02:00
component: 'textProperties',
category: 'textProperties',
properties: textProps,
2020-06-09 22:06:26 +02:00
defaultValues: {fontSize:0,lineHeight:0,letterSpacing:0,wordSpacing:0},
Interpolate: {units},
functions: textPropFunctions,
Util: {trueDimension}
}
export default textProperties
Components.TextProperties = textProperties