Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/binocarlos/pagehammer
Touch event handler for pageturner books
https://github.com/binocarlos/pagehammer
Last synced: 11 days ago
JSON representation
Touch event handler for pageturner books
- Host: GitHub
- URL: https://github.com/binocarlos/pagehammer
- Owner: binocarlos
- Created: 2014-07-08T15:48:44.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-07-15T11:41:46.000Z (over 10 years ago)
- Last Synced: 2024-04-14T14:36:44.975Z (7 months ago)
- Language: JavaScript
- Size: 160 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
pagehammer
==========Touch event handler for turning books
## installation
```
$ component install binocarlos/pagehammer
```## example
Create a pagehammer and assign it to a DOM element.
```js
var PageHammer = require('pagehammer')var book = document.createElement('div')
var hammer = PageHammer()hammer.setup(book)
hammer.on('swipe', function(direction, toPage){
// direction is 'left' or 'right'
})book.appendTo(document.querySelector('#container'))
```## api
#### `var hammer = PageHammer(opts)`
The options object has the following properties:
* minDistance - the minimum distance a swipe has to be in pixels
#### `hammer.setup(elem)`
Setup the pagehammer on the given DOM element
## events
#### `hammer.on('swipe', function(side, direction){})`
triggered when the page has been turned because of a swipe.
The side is 'left' or 'right' and direction is -1 or 1
## licence
MIT