Viewport isTouch Checker jQuery viewportInfo - Download jQuery Based Viewport Size And isTouch Checker - viewportInfo

Download jQuery Based Viewport Size And isTouch Checker – viewportInfo

Posted on

This time I will share jQuery Plugin and tutorial about jQuery Based Viewport Size And isTouch Checker – viewportInfo, hope it will help you in programming stack.

Viewport isTouch Checker jQuery viewportInfo - Download jQuery Based Viewport Size And isTouch Checker - viewportInfo

File Size: 3.07 KB
Views Total: 492
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

viewportInfo is a jQuery plugin that detects the current viewport size (Desktop, Mobile, Tablet) and checks if the current device is touchable.

How to use it:

1. Load the JavaScript file viewportInfo.js after jQuery library and the viewportInfo is read for use.

1 <script src="//code.jquery.com/jquery-3.2.1.slim.min.js"></script>
2 <script src="viewportInfo.js"></script>

2. Create the html elements to display the results.

1 <div id="viewport-size">Viewport Size: <span class="label"></span></div>
2 <div id="touch-info">Touch Enabled: <span class="label"></span></div>

3. Initialize the plugin and set the screen resolutions as follow.

1 viewportInfo.init({
2   viewports: {
3     mobile: 767,
4     tablet: 959,
5     desktop: 1159
6   }
7 })

4. The plugin provides a callback function which will be fired on viewport change.

01 viewportInfo.init({
02   viewports: {
03     mobile: 767,
04     tablet: 959,
05     desktop: 1159
06   }
07 }).onChange(function(viewport,isTouch){
08   $('#viewport-size .label').text(viewport);
09   $('#touch-info .label').text(isTouch);
10 },true)

This awesome jQuery plugin is developed by faraazmalak. For more Advanced Usages, please check the demo page or visit the official website.

source : jqueryscript.net