diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..0f7417e --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,14 @@ + +# 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)) + + + diff --git a/README.md b/README.md index f4c4388..4eeb30e 100644 --- a/README.md +++ b/README.md @@ -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'; + +} +``` +

+ +## 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'); + }); + +}); +``` \ No newline at end of file