mirror of
https://github.com/zoriya/react-native-web.git
synced 2026-05-25 07:34:45 +00:00
use 'normalizeValue' in 'processTransform'
This commit is contained in:
@@ -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) => {
|
||||
|
||||
@@ -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})`
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user