app.unit
Unit conversion utility. This help us convert unit (as example dp to px) easily.
Constants#
| Name | Type | Description | 
|---|---|---|
| Types | object | Unit constants. We use this for parameters of app.unit.convert | 
Methods#
| Name | Return Type | Description | 
|---|---|---|
| convert | number | Scale a number based on two units. | 
| resolve | number | Resolve unit suffix of a string then convert it to px. | 
convert#
Scale a number based on two units. If toUnit ignored, then destination unit assumed as px.
Parameters:
- value: (number type) a Number to be converted
 - fromUnit: (number type) Unit of value. Use 
app.unit.Types.*for this parameter. - toUnit: (number type, Optional) Unit of result. Use 
app.unit.Types.*for this parameter. 
Return: number
resolve#
Resolve unit suffix of a string then convert it to px. However, if the value is number then returns that value.
Parameters:
- value: (string or number type) a String that contains number with unit or just a plain number.
 - percentFactor: (number type, Optional) This parameter tells 
"100%"is equals what pixels. If ignored, then"100%" == "100px". 
Return: number