Class: g

g

Also can be called without 'new'

new g(elem)

Parameters:
Name Type Description
elem string, array, object required. String(selector), DOM element, DOM element Array, NodeList, HTMLCollection or jQuery Object
Source:
  • gesture.js, line 14

Members

<static> event

Properties:
Name Type Description
g.event.touchstart string 'touchstart' or 'mousedown'.
g.event.touchmove string 'toucmove' or 'mousemove'.
g.event.touchend string 'touchend' or 'mouseup'.
Source:
  • gesture.js, line 412

<static> support

Properties:
Name Type Description
g.support.touch boolean If touch event supported.
g.support.gesture boolean If gesture event supported.
Source:
  • gesture.js, line 423

<static> util

Properties:
Name Type Description
g.util.getPageX function @see .util.getPageX
g.util.getPageY function @see .util.getPageY
g.util.getDistance function @see .util.getDistance
g.util.extend function @see .util.extend
Source:
  • gesture.js, line 432

draggable

draggable
Source:
  • dragdrop.js, line 10

Methods

<static> createEvent(type, e, attrs)

fire an event(logicly)
Parameters:
Name Type Description
type string required. Event type.
e event optional. The relatived original event. touchend or mouseup normally.
attrs object optional. Some additional attribute. such as 'currentTarget', 'targets', 'direction'(flick)
Source:
  • gesture.js, line 176
Returns:
g class.

<static> opt(k)

set or get some config data
Parameters:
Name Type Description
k string, object a string key or an object contains key-value pairs.
v. any
Source:
  • gesture.js, line 159
Returns:
If k is an object, then return undefined, otherwise the value of g.opt(k)

<static> register(type, handler, ifBind)

Regiester an event type. used to extend this framework.
Parameters:
Name Type Description
type string The event type to regiester.
handler object A object contains 3 methods named 'touchstart', 'toucmove', 'touchend'
ifBind function This function will be executed when bind this event to an element.
Source:
  • gesture.js, line 125
Returns:
g class

<static> To convert the element(s) specified by the parameter 'elem' into an array.() → {Array}

Parameters:
Type Description
jQuery, HTMLElement, String, NodeList, HTMLCollection, Array
Source:
  • gesture.js, line 449
Returns:
an array contains some dom node element(HTMLElement).
Type
Array

<static> unregister(event)

Unregiester an event type. this function will not be used normally.
Parameters:
Name Type Description
event string event type, such as 'tap'.
Source:
  • gesture.js, line 145
Returns:
g class

.util.extend(to, from)

copy @param from attributes to @param to.
Parameters:
Name Type Description
to object required
from object required
Source:
  • gesture.js, line 541

.util.getDistance(p0, p1) → {number}

calculate the distance between 2 points
Parameters:
Name Type Description
p0 array format: [x0, y0]
p1 array format: [x1, y1]
Source:
  • gesture.js, line 529
Returns:
the distance
Type
number

.util.getPageX(e) → {number}

Parameters:
Name Type Description
e event touch or mouse event.
Source:
  • gesture.js, line 485
Returns:
pageX or clientX attribute
Type
number

.util.getPageY(e) → {number}

Parameters:
Name Type Description
e event touch or mouse event.
Source:
  • gesture.js, line 497
Returns:
pageY or clientY attribute
Type
number

off(type, selector, callback) → {g}

Unbind events.
Parameters:
Name Type Description
type string required. Event type, name space supported, separated by spaces if more than one, such as 'tap taphold.namespace'.
selector string optional. Unbind these events bind to child nodes.
callback function optional.
Source:
  • gesture.js, line 59
Returns:
Current g instance.
Type
g

on(type, selector, data, callback) → {g}

bind events.
Parameters:
Name Type Description
type string required. Event type, name space supported, separated by spaces if more than one, such as 'tap taphold.namespace'.
selector string optional. Delegate these events to its child nodes=querySelectorAll(selector)。
data object optional. Passing some data to callback.
callback function required.
Source:
  • gesture.js, line 31
Returns:
Current g instance.
Type
g

trigger(type) → {g}

Fire a event manually
Parameters:
Name Type Description
type string required. Event type. such as 'tap'.
Source:
  • gesture.js, line 109
Returns:
Current g instance.
Type
g