# Global

##

### Methods

#### gesture($elements, handlerName, userOptions)

  Handle touch and mouse event

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `$elements` | HTMLElement | Array.<HTMLElement> | DOM element or DOMList element
  `handlerName` | String | Name of the handler used to retrieve it and unbind events with gestureOff
  `userOptions` | Object | ###### Properties
  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `selector` | String | <optional> |  | Used for event delegation
  `start` | gestureEvents_Callback | <optional> |  | touchstart, pointerdown, mousedown
  `move` | gestureEvents_Callback | <optional> |  | touchmove, pointermove, mousemove
  `end` | gestureEvents_Callback | <optional> |  | touchend, pointerup, mouseup
  `click` | gestureEvents_Callback | <optional> |  | click
  `tap` | gestureEvents_Callback | <optional> |  | touchend on touch device, click on other
  `swipeLeft` | gestureCustomEvents_Callback | <optional> |  |
  `swipeRight` | gestureCustomEvents_Callback | <optional> |  |
  `swipeUp` | gestureCustomEvents_Callback | <optional> |  |
  `swipeDown` | gestureCustomEvents_Callback | <optional> |  |
  `swipe` | gestureSwipeEvent_Callback | <optional> |  |
  `moveLeft` | gestureCustomEvents_Callback | <optional> |  |
  `moveRight` | gestureCustomEvents_Callback | <optional> |  |
  `moveUp` | gestureCustomEvents_Callback | <optional> |  |
  `moveDown` | gestureCustomEvents_Callback | <optional> |  |
  `threshold` | Number | <optional> | 20 | In px, minimal distance to do to trigger events
  `useTouch` | Boolean | <optional> | true | Use all touch, pointer or mouse events, or only click event
  `velocityMax` | Number | <optional> | -1 | Cap valocity
  `angleThreshold` | Number | <optional> | 2 | In deg, sensitivity of angle detection
  `preventClick` | Boolean | function | <optional> | false | Prevent click
  `stopPropagationClick` | Boolean | function | <optional> | false | Stop propagation of click
  `preventStart` | Boolean | function | <optional> | false | Prevent touchstart, pointerdown, ...
  `stopPropagationStart` | Boolean | function | <optional> | false | Stop propagation of touchstart, pointerdown, ...
  `preventMove` | Boolean | function | <optional> | false | Prevent touchmove, pointermove, ...
  `stopPropagationMove` | Boolean | function | <optional> | false | Stop propagation of touchmove, pointermove, ...
  `preventEnd` | Boolean | function | <optional> | false | Prevent touchend, pointerup, ...
  `stopPropagationEnd` | Boolean | function | <optional> | false | Stop propagation of touchend, pointerup, ...

  See:
    - For more details, see extra/events.md

  ##### Returns:

  - The handler (or array of handlers) to unbind events
  Type
    object | Array

  ##### Example

      let gestureHanlder = gesture( $element, 'handlerName', options );

      // To cancel
      gestureOff( $element, 'handlerName' );

      // or
      gestureHanlder.off();

#### gestureOff($elements, handlerName)

  Remove touch and mouse event

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `$elements` | HTMLElement | Array.<HTMLElement> | DOM element or DOMList element
  `handlerName` | String | Name of the handler to unbind events

  ##### Example

      gestureOff( $element, 'handlerName' );

### Type Definitions

#### gestureCustomEvents_Callback(e, $target, type)

  Called when custom event (swipeLeft, swipeUp, moveUp, ... but not swipe) are fired

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `e` | Event | Original events
  `$target` | HTMLElement | Targeted element (direct or by delegation)
  `type` | String | Name of the event

#### gestureEvents_Callback(e, $target, coords, type)

  Called when original events (touchstart, mousedown, pointerdown, ...) are fired

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `e` | Event | Original events. For move and end events, e.currentTarget point to document.body. Use the $target param instead.
  `$target` | HTMLElement | Targeted element (direct or by delegation)
  `coords` | Object | Coordinates of the pointer ###### Properties
  Name | Type | Description
  --- | --- | ---
  `pageX` | Number |
  `pageY` | Number |
  `clientX` | Number |
  `clientY` | Number |
  `mode` | String | touch | mouse | pointer | click
  `type` | String | Name of the event

#### gestureSwipeEvent_Callback(e, $target, type, velocityData)

  Called when the swipe event is fire

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `e` | Event | Original events
  `$target` | HTMLElement | Targeted element (direct or by delegation)
  `type` | String | Name of the event
  `velocityData` | Object | ###### Properties
  Name | Type | Description
  --- | --- | ---
  `velocity` | Number | Last computed velocity of the movement in px / seconds
  `averageVelocity` | String | Average velocity of the whole movment in px / seconds
  `angle` | String | In deg
  `direction` | String | up | down | left | right | up-right | down-right | up-left |down-left | none

#### Search results