-
<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:
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:
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:
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:
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:
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:
-
.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:
Returns:
the distance
-
Type
-
number
-
.util.getPageX(e) → {number}
-
Parameters:
Name |
Type |
Description |
e |
event
|
touch or mouse event. |
- Source:
Returns:
pageX or clientX attribute
-
Type
-
number
-
.util.getPageY(e) → {number}
-
Parameters:
Name |
Type |
Description |
e |
event
|
touch or mouse event. |
- Source:
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:
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:
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:
Returns:
Current g instance.
-
Type
-
g