A 'Shake to Undo' JavaScript plugin for iOS Mobile Safari/Webkit
Switch branches/tags
Nothing to show
Pull request Compare This branch is 63 commits behind alexgibson:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
README
WKShake.js
index.html

README

WKShake

Usage

Note: this plugin requires iOS 4.2.1 or later.

First, include the main JavaScript file in the header of your HTML document:

<script type="text/javascript" src="WKShake.js" ></script>

Next, include the following JavaScript just before the end </body> tag in your HTML to create a new instance of the plugin. Put your own code within the shakeEventDidOccur() method for what you want to happen when a shake event occurs.

<script type="text/javascript"> 
window.onload = function() {

	//create a new instance of WKShake.
	var myShakeEvent = new WKShake();

	//start listening for shake event. 
	//you can also use stop() to stop listening.
	myShakeEvent.start();
	
	//define a custom method to fire when shake occurs.
	myShakeEvent.shakeEventDidOccur = function() {
	
		//put your own code here etc.
		if (confirm("Undo?")) {

		}
	}
};
</script>