https://github.com/lcluber/indium.js
Touchscreen events library
https://github.com/lcluber/indium.js
Last synced: about 1 month ago
JSON representation
Touchscreen events library
- Host: GitHub
- URL: https://github.com/lcluber/indium.js
- Owner: LCluber
- License: mit
- Created: 2019-04-09T12:53:59.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-06T22:17:16.000Z (over 3 years ago)
- Last Synced: 2025-01-03T16:50:02.474Z (over 1 year ago)
- Language: TypeScript
- Size: 2.06 MB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 18
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
## Synopsis
**Indium.js** is a touch gestures library written in TypeScript with multiple touches detection.
## Motivation
The purpose of this library is to provide a simple and easy way to add touch gestures to your app.
## Installation
### NPM
```bash
$ npm install @lcluber/indiumjs
```
### Yarn
```bash
$ yarn add @lcluber/indiumjs
```
## Demo
See a basic example **[here](http://vortalcombat.roostrjs.com)**.
## Usage
### ES6
```html
```
```javascript
import { TouchScreen, Right } from '@lcluber/indiumjs';
function shipMove(touch) {
console.log('touch',touch);
}
function shipStop(touch) {
console.log('end',touch);
}
function shipShoot(touch) {
console.log('shoot',touch);
}
var touchScreen = new TouchScreen('myCanvas');
touchScreen.touchStart(shipMove);
touchScreen.touchMove(shipMove);
touchScreen.touchEnd(shipStop);
touchScreen.touchCancel(shipStop);
var bottom = new Right(0.3);
bottom.touchStart(shipShoot);
touchScreen.addZone(bottom);
```
### IIFE
```html
```
```javascript
function shipMove(touch) {
console.log('touch',touch);
}
function shipStop(touch) {
console.log('end',touch);
}
function shipShoot(touch) {
console.log('shoot',touch);
}
var touchScreen = new Indium.TouchScreen('myCanvas');
touchScreen.touchStart(shipMove);
touchScreen.touchMove(shipMove);
touchScreen.touchEnd(shipStop);
touchScreen.touchCancel(shipStop);
var bottom = new Indium.Right(0.3);
bottom.touchStart(shipShoot);
touchScreen.addZone(bottom);
```
## API Reference
```javascript
type TZone = Top | Right | Bottom | Left;
TouchScreen.touchStart(callback: Function);
TouchScreen.touchMove(callback: Function);
TouchScreen.touchEnd(callback: Function);
TouchScreen.touchCancel(callback: Function);
touchScreen.addZone(zone: TZone);
Top.touchStart(callback: Function);
Top.touchMove(callback: Function);
Top.touchEnd(callback: Function);
Top.touchCancel(callback: Function);
Left.touchStart(callback: Function);
Left.touchMove(callback: Function);
Left.touchEnd(callback: Function);
Left.touchCancel(callback: Function);
Right.touchStart(callback: Function);
Right.touchMove(callback: Function);
Right.touchEnd(callback: Function);
Right.touchCancel(callback: Function);
Bottom.touchStart(callback: Function);
Bottom.touchMove(callback: Function);
Bottom.touchEnd(callback: Function);
Bottom.touchCancel(callback: Function);
```
## Tests
No tests to run yet
## Contributors
There is still a lot of work to do on this project and I would be glad to get all the help you can provide.
To contribute you can clone the project on **[GitHub](https://github.com/LCluber/Indium.js)** and see **NOTICE.md** for detailed installation walkthrough of the project.
## License
MIT License
Copyright (c) 2016 Ludovic CLUBER
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.