mirror of
https://github.com/zoriya/react-native-web.git
synced 2026-06-03 02:42:05 +00:00
use 'normalizeValue' in 'processTransform'
This commit is contained in:
@@ -19,7 +19,12 @@ const unitlessNumbers = {
|
|||||||
fillOpacity: true,
|
fillOpacity: true,
|
||||||
strokeDashoffset: true,
|
strokeDashoffset: true,
|
||||||
strokeOpacity: true,
|
strokeOpacity: true,
|
||||||
strokeWidth: true
|
strokeWidth: true,
|
||||||
|
// transform types
|
||||||
|
scale: true,
|
||||||
|
scaleX: true,
|
||||||
|
scaleY: true,
|
||||||
|
scaleZ: true
|
||||||
}
|
}
|
||||||
|
|
||||||
const normalizeValue = (property, value) => {
|
const normalizeValue = (property, value) => {
|
||||||
|
|||||||
@@ -1,21 +1,10 @@
|
|||||||
const translateProperties = {
|
import normalizeValue from './normalizeValue'
|
||||||
translateX: true,
|
|
||||||
translateY: true,
|
|
||||||
translateZ: true
|
|
||||||
}
|
|
||||||
|
|
||||||
const processTransformValue = (key, value) => {
|
|
||||||
if (translateProperties[key] && typeof value === 'number') {
|
|
||||||
value += 'px'
|
|
||||||
}
|
|
||||||
return value
|
|
||||||
}
|
|
||||||
|
|
||||||
// { scale: 2 } => 'scale(2)'
|
// { scale: 2 } => 'scale(2)'
|
||||||
// { translateX: 20 } => 'translateX(20px)'
|
// { translateX: 20 } => 'translateX(20px)'
|
||||||
const mapTransform = (transform) => {
|
const mapTransform = (transform) => {
|
||||||
const type = Object.keys(transform)[0]
|
const type = Object.keys(transform)[0]
|
||||||
const value = processTransformValue(type, transform[type])
|
const value = normalizeValue(type, transform[type])
|
||||||
return `${type}(${value})`
|
return `${type}(${value})`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user