Methods
(static) getRangedMediaExactValue(rule, unit) → {number}
Returns the exact value of a ranged CSS media query.
Example
// determines the exact value of the "width" media query in "vw" units
console.log(viewstat.media.getRangedMediaExactValue("width", "vw")); // result should be 100
Parameters:
Name | Type | Description |
---|---|---|
rule |
string | |
unit |
string | CSS unit in which the result is determined. |
Returns:
- Type
- number
(static) supportsMediaFeature(rule) → {boolean}
Checks if a specific media query is supported.
Example
// check if the "resolution" media query is supported
console.log(viewstat.media.supportsMediaFeature("resolution"));
Parameters:
Name | Type | Description |
---|---|---|
rule |
string | Name of the query. |
Returns:
- Type
- boolean
(static) supportsMediaQueries() → {boolean}
Checks if CSS media queries are supported.
Example
// check if media queries are available
console.log(viewstat.media.supportsMediaQueries());
Returns:
- Type
- boolean
(static) supportsRangedMediaUnit(rule, unit) → {boolean}
Determines if a ranged media query rule supports a specified CSS unit.
- Description:
This method is not intended to work on any media query, only those that support a min- and max- prefix.
Example
// checks if the "resolution" media query supports the "dppx" unit.
const supports_resolution_in_dppx = viewstat.media.supportsRangedMediaUnit("resolution", "dppx");
console.log(supports_resolution_in_dppx);
Parameters:
Name | Type | Description |
---|---|---|
rule |
string | |
unit |
string |
Returns:
- Type
- boolean