Detecting Phone shake using jQuery ios-shake.js

Detect phone shake using jQuery (Last Updated On: March 21, 2016)

Detecting Phone shake using jQuery ios-shake.js:

We all are having smart phones and checking all the details/shoppings/study everything with mobile only. So all the companies are changing and concentrating more on mobile view/mobile apps than web developments. Even we are already having many mobile apps to change the songs based on the mobile shake. Today we are going to see the phone detection using used jquery ios shake js and it is expected to be implemented in all the areas soon.

demo
download

Required JS Files:
1. jQuery plugin
2. jQuery ios-shake plugin

 

Detecting Phone Shake using jQuery Source code:
We have used jquery.ios-shake.js to observe the phone shaking. $.shake will be called if phone shaked.

<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui">
    <title>Detect shake in phone using Jquery</title>
	<script type="text/javascript" src="jquery-1.11.2.min.js"></script>
    <script type="text/javascript" src="jquery.ios-shake.js"></script>
    <script type="text/javascript">
        $(document).ready(function() {
            $.shake({
                callback: function() {
				alert("Follow us on facebook.com/javadomain");
                }
            });
        });
    </script>
</head>
<body>
<div id="content">
<h1>Detecting Phone shake using jQuery</h1>
<h4>Javadomain.in</h4>
</div>
<div id="welcome">Shake your phone to get the alert</div>
</body>
</html>

 

Output:

Phone shake detection output1

 

After shaking the phone:

Phone shake detection output2

 

 

jQuery Recommended Books:

257 total views, 2 views today

Leave a Reply

Your email address will not be published. Required fields are marked *