Encore device detector
Provide methods to identify device type and set specific CSS class.
Install
$ npm install encore-device-detector
Usage
- Import DeviceDetector class
- Create an instance and use it
Documentation
Library allows us to detect several device types:
- mobile
- tablet
- desktop
- ios
It also allows us to detect some specific browsers:
- ie
- edge
- safari
And detect orientation:
- portrait
- landscape
Methods
setDeviceRelatedClassnames - Check device and browser and add specific CSS classes (available options: encore-mobile, encore-tablet, encore-desktop, encore-ie, encore-edge, encore-safari). Classes are configurable and can be changed using classNameConfiguration parameter
isTablet - Check if device is tablet
isMobile - Check if device is mobile
isDesktop - Check if device is desktop
isIE - Check if browser is IE
isEdge - Check if browser is Edge
isSafari - Check if browser is Safari
isPortrait - Check if portrait orientation
isLandscape - Check if landscape orientation