Skip to content

Commit

Permalink
docs(lib): README
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzodianni committed Apr 12, 2018
1 parent 2375d01 commit 49c69d3
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 1 deletion.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<a name="1.0.0"></a>
# 1.0.0 (2018-04-12)


### Features

* **core:** event | pointer | touch ([395fddd](https://github.com/lorenzodianni/gesture-events/commit/395fddd))
* **lib:** declaration file ([75636f7](https://github.com/lorenzodianni/gesture-events/commit/75636f7))
* **lib:** setup ([423234c](https://github.com/lorenzodianni/gesture-events/commit/423234c))
* **swipe:** simulate swipe gesture ([9905067](https://github.com/lorenzodianni/gesture-events/commit/9905067))
* **tap:** simulate tap gesture ([eacf40f](https://github.com/lorenzodianni/gesture-events/commit/eacf40f))



63 changes: 62 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,63 @@
# gesture
# Gesture Events
Test utilities that simulate swipe/tap gestures

```ssh
npm install gesture-events --save-dev
```

#### API
```
GestureEvents {
export function swipe(el: HTMLElement | Document, from: Pointer, to: Pointer): void;
export function tap(el: HTMLElement | Document, position?: Pointer): void;
export interface Pointer {x: number, y: number}
export type EventName = 'touchstart' | 'touchmove' | 'touchend';
}
```
<br><br>

## Examples
### swipe
> swipe(el: HTMLElement | Document, from: Pointer, to: Pointer): void
```js
import {swipe, Pointer} from 'gesture-events';

describe('Change background color on document swipe', () => {

test('should change color if user swipe x more than 30px', () => {
const from: Pointer = {x: 30, y: 10};
const to: Pointer = {x: 70, y: 10};

expect(document.body.style.backgroundColor).toBe('');

swipe(document.body, from, to);

expect(document.body.style.backgroundColor).toBe('red');
});

});
```

### tap
> tap(el: HTMLElement | Document, position?: Pointer): void
```js
import {tap} from 'gesture-events';

describe('Change background color on document tap', () => {

test('should change on user tap', () => {

expect(document.body.style.backgroundColor).toBe('');

tap(document.body);

expect(document.body.style.backgroundColor).toBe('red');
});

});
```

0 comments on commit 49c69d3

Please sign in to comment.