Created
October 8, 2014 12:59
-
-
Save dameleon/a60a6e056d9705c8a7fa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
paw.js | |
====== | |
## how to use | |
### simplest use | |
``` | |
// initialize | |
new Paw(); | |
// handling event | |
var element = document.getElementById('someElement'); | |
element.addEventListener('tap', function() { | |
alert('tap!'); | |
}); | |
// with jQuery | |
$('#someElement').on('tap', function() { | |
alert('tap!'); | |
}); | |
``` | |
### with options | |
Paw.js argumments & options | |
``` | |
function Paw(rootNode, option) {...} | |
``` | |
- rootNode | |
- type: Document|Node | |
- default: window.document | |
- optional | |
- option | |
- type: Object | |
- optional | |
- option.pressDuration | |
- type: Number | |
- default: `500` | |
- optional | |
- option.doubleTapDuration | |
- type: Number | |
- default: `400` | |
- optional | |
- option.motionThreshold | |
- type: Number | |
- default: `5` | |
- optional | |
- option.fastClick | |
- type: Boolean | |
- default: `true` | |
- optional | |
#### specify the element to handling the Paw.js events | |
##### html | |
``` | |
<html> | |
<head>...</head> | |
<body> | |
<div id="toucharea"> | |
<button id="toucharea-btn">btn</button> | |
</div> | |
<div> | |
<button id="normal-btn">btn</button> | |
</div> | |
</body> | |
</html> | |
``` | |
##### javascript | |
``` | |
var toucharea = document.getElementById('toucharea'); | |
new Paw(toucharea); | |
// the toucharea-btn can handle the "tap" event | |
document.getElementById('toucharea-btn').addEventListener('tap', function() { | |
alert('tap!'); | |
}); | |
// the normal-btn cannot handle the "tap" event | |
document.getElementById('normal-btn').addEventListener('tap', function() { | |
// never call | |
}); | |
``` | |
#### specify options | |
``` | |
new Paw(null, { | |
pressDuration: , | |
doubleTapDuration: , | |
motionThreshold: , | |
fastClick: | |
}); | |
``` | |
## Author | |
[twitter@dameleon](https://twitter.com/damele0n) | |
## License | |
Paw.js is licensed under MIT licensed. | |
See [LICENSE](https://github.com/dameleon/paw.js/blob/master/LICENSE) for more information. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment