Class “Percent”
Represents a percentage. See also PercentValue
| Type: | Percent extends Object |
| Constructor: | public |
| Singleton: | No |
| Namespace: | tabris |
| Direct subclasses: | None |
| JSX Support: | No |
Constructor
new Percent(value)
| Parameter | Type | Description |
|---|---|---|
| value | number |
A number between and including 0 and 100 |
Methods
toString()
Returns a string representation of the percent (a number followed by ‘%’).
Returns: string
valueOf()
Returns the percent number
Returns: number
Static Methods
from(percentValue)
Creates a new instance of Percent using any valid percent expression. For any other value, including null the method throws.
| Parameter | Type | Description |
|---|---|---|
| percentValue | PercentValue |
The value to create a Percent instance from |
Returns: Percent
isValidPercentValue(value)
Returns true if value is a valid PercentValue. This excludes null. Use this to check if a value will be accepted by Percent.from. This is also a valid TypeScript type guard function.
| Parameter | Type | Description |
|---|---|---|
| value | any |
The value to test |
Returns: value
Properties
percent
A number between and including 0 and 100
| Type: | number |
| Settable: | No |
This property can only be set via constructor. Once set, it cannot change anymore.
Related Types
PercentValue
- JavaScript Type:
tabris.Percent,Object,string - TypeScript Type:
tabris.PercentValue
Represents a percentage. This type includes various expressions that can all be used in place of a Percent instance for convenience. All APIs that accept these expressions will convert them to a Percent object.
In TypeScript you can import this type as a union with import {PercentValue} from 'tabris'; or use tabris.PercentValue. A Type guard for PercentValue is available as Percent.isValidPercentValue.
In addition to Percent instances PercentValue includes:
PercentLikeObject
- JavaScript Type:
Object - TypeScript Type:
tabris.PercentLikeObject
export interface PercentLikeObject {
percent: number;
}
A plain object in the format of {percent: number}, where 100 presents 100%.
Examples:
widget.left = {percent: 50};
PercentString
A number followed by %.
Example: '50%'