@okiba/detect
v1.0.9
Published
Feature detection
Downloads
42
Readme
Okiba / detect
Utilities to check some browser features
Installation
npm i --save @okiba/detect
Or import it directly in the browser
<script type="module" src="https://unpkg.com/@okiba/detect/index.js"></script>
Usage
import detect from '@okiba/detect'
Untranspiled code 🛑
Okiba UI packages are not transpiled, so don't forget to transpile them with your favourite bundler. For example, using Babel with Webpack, you should prevent imports from okiba to be excluded from transpilation, like follows:
{
test: /\.js$/,
exclude: /node_modules\/(?!(@okiba)\/).*/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
}
hasPassiveEvents()
Check if browser supports passive events
import {hasPassiveEvents} from '@okiba/detect'
console.log(hasPassiveEvents) // true
Returns
Boolean
true if browser supports passive events
hasTouch()
Check if browser has touch support
import {hasTouch} from '@okiba/detect'
console.log(hasTouch) // true
Returns
Boolean
true if browser has touch support