image/imageresize/utils/tryparsedimensionwithunit
 module
Type Definitions
- module:image/imageresize/utils/tryparsedimensionwithunit~DimensionWithUnit
Functions
- tryCastDimensionsToUnit( parentDimensionPx, dimension, targetUnit ) → DimensionWithUnitinternal- module:image/imageresize/utils/tryparsedimensionwithunit~tryCastDimensionsToUnit- Converts dimension between - px->- %and- %->- px.- Parameters- parentDimensionPx : number
- Dimension of parent element that contains measured element. 
- dimension : DimensionWithUnit
- Measured element dimension. 
- targetUnit : string
 - Returns- DimensionWithUnit
- Casted dimension. 
 
- tryParseDimensionWithUnit( dimension ) → null | DimensionWithUnitinternal- module:image/imageresize/utils/tryparsedimensionwithunit~tryParseDimensionWithUnit- Parses provided string with dimension value and returns extracted numeric value and unit. - * If non-string dimension is passed then `null` value is returned. * If unit is missing then `null` is returned. * If numeric value part of string is not a number then `null` is returned.Copy code- Example: - "222px"=>- { value: 222, unit: "px" }- "99%"=>- { value: 99, unit: "%" }- Parameters- dimension : undefined | null | string
- Unsafe string with dimension. 
 - Returns- null | DimensionWithUnit
- Parsed dimension with extracted numeric value and units.