image/imageresize/utils/tryparsedimensionwithunit
module
Type Definitions
-
module:image/imageresize/utils/tryparsedimensionwithunit~DimensionWithUnit
Functions
-
tryCastDimensionsToUnit( parentDimensionPx, dimension, targetUnit ) → DimensionWithUnitinternalmodule:image/imageresize/utils/tryparsedimensionwithunit~tryCastDimensionsToUnitConverts dimension between
px->%and%->px.Parameters
parentDimensionPx : numberDimension of parent element that contains measured element.
dimension : DimensionWithUnitMeasured element dimension.
targetUnit : string
Returns
DimensionWithUnitCasted dimension.
-
tryParseDimensionWithUnit( dimension ) → null | DimensionWithUnitinternalmodule:image/imageresize/utils/tryparsedimensionwithunit~tryParseDimensionWithUnitParses 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 codeExample:
"222px"=>{ value: 222, unit: "px" }"99%"=>{ value: 99, unit: "%" }Parameters
dimension : undefined | null | stringUnsafe string with dimension.
Returns
null | DimensionWithUnitParsed dimension with extracted numeric value and units.