Documentation
A module for determining the type of device and orientation. This module allows you to check whether the device is a mobile phone, tablet, or desktop, as well as determine their orientation.
Usage
Import the module into your JS:
import { devices } from '@lukovio/wskit';
Example Usage
if (devices.mobile()) {
doSomethingOnMobileOnly();
} else if (devices.tablet()) {
doSomethingOnTabletOnly();
} else {
doSomethingOnDesktop();
}
API
smallMobile()
Checks if the device is a small mobile.
Dimensions:
- Maximum width: 320px
Returns:
- (boolean):
trueif the device is a small mobile, otherwisefalse.
smallMobileLandscape()
Checks if the device is a small mobile in landscape orientation.
Dimensions:
- Maximum height: 320px
- Orientation: landscape
Returns:
- (boolean):
trueif the device is a small mobile and in landscape orientation, otherwisefalse.
smallMobilePortrait()
Checks if the device is a small mobile in portrait orientation.
Dimensions:
- Maximum width: 320px
- Orientation: portrait
Returns:
- (boolean):
trueif the device is a small mobile and in portrait orientation, otherwisefalse.
mobile()
Checks if the device is mobile.
Dimensions:
- Maximum width: 767px
Returns:
- (boolean):
trueif the device is mobile, otherwisefalse.
mobileLandscape()
Checks if the device is mobile in landscape orientation.
Dimensions:
- Maximum height: 767px
- Orientation: landscape
Returns:
- (boolean):
trueif the device is mobile and in landscape orientation, otherwisefalse.
mobilePortrait()
Checks if the device is mobile in portrait orientation.
Dimensions:
- Maximum width: 767px
- Orientation: portrait
Returns:
- (boolean):
trueif the device is mobile and in portrait orientation, otherwisefalse.
tablet()
Checks if the device is a tablet.
Dimensions:
- Minimum width: 768px
- Maximum width: 1024px
Returns:
- (boolean):
trueif the device is a tablet, otherwisefalse.
tabletLandscape()
Checks if the device is a tablet in landscape orientation.
Dimensions:
- Minimum width: 768px
- Maximum width: 1024px
- Orientation: landscape
Returns:
- (boolean):
trueif the device is a tablet and in landscape orientation, otherwisefalse.
tabletPortrait()
Checks if the device is a tablet in portrait orientation.
Dimensions:
- Minimum width: 768px
- Maximum width: 1024px
- Orientation: portrait
Returns:
- (boolean):
trueif the device is a tablet and in portrait orientation, otherwisefalse.
desktop()
Checks if the device is a desktop.
Dimensions:
- Minimum width: 1025px
Returns:
- (boolean):
trueif the device is a desktop, otherwisefalse.
Notes
This module allows hiding and expanding long texts. Users can see only a portion of the text, and by clicking the “Read more” button, they can reveal the rest. The module also supports setting an active class for customizing the appearance.