use 'normalizeValue' in 'processTransform'

This commit is contained in:
Nicolas Gallagher
2016-07-07 22:24:05 -07:00
parent 37f2d78f34
commit 44fc48f7a0
2 changed files with 8 additions and 14 deletions
+6 -1
View File
@@ -19,7 +19,12 @@ const unitlessNumbers = {
fillOpacity: true,
strokeDashoffset: true,
strokeOpacity: true,
strokeWidth: true
strokeWidth: true,
// transform types
scale: true,
scaleX: true,
scaleY: true,
scaleZ: true
}
const normalizeValue = (property, value) => {
+2 -13
View File
@@ -1,21 +1,10 @@
const translateProperties = {
translateX: true,
translateY: true,
translateZ: true
}
const processTransformValue = (key, value) => {
if (translateProperties[key] && typeof value === 'number') {
value += 'px'
}
return value
}
import normalizeValue from './normalizeValue'
// { scale: 2 } => 'scale(2)'
// { translateX: 20 } => 'translateX(20px)'
const mapTransform = (transform) => {
const type = Object.keys(transform)[0]
const value = processTransformValue(type, transform[type])
const value = normalizeValue(type, transform[type])
return `${type}(${value})`
}