/is-mobile

Custom Element for detecting mobile browser

Primary LanguageHTML

<is-mobile>

Custom web component element to detect mobile browser, based on script here.

Install

Install the component using Bower:

$ bower install is-mobile --save

Or download as ZIP.

Usage

  1. Import Web Components polyfill:

    <script src="bower_components/webcomponentsjs/webcomponents.min.js"></script>
  2. Import the element:

    <link rel="import" href="bower_components/is-mobile/is-mobile.html">
  3. Use the element:

    <is-mobile></is-mobile>

Attribute

mobile - boolean - indicates whether mobile browser is detected. The attribute is set only once on the creation of the element. It should not be set or overwritten, otherwise the value will be lost.

For example, this is how the element will appear on mobile browser:

<is-mobile mobile="true"></is-mobile>

Also, document.querySelector("is-mobile").mobile will return boolean true.

License

MIT License