Class Utils
Class defined in:src/utils.js:1
extend
( dest, src, [merge=false]
)
src/utils.js:8
extend method, could also be used for cloning when dest
is an empty object.
changes the dest object
dest
getAngle
( touch1, touch2
)
src/utils.js:208
calculate the angle between two coordinates
Parameters:angle
getCenter
( touches
)
src/utils.js:152
get the center of all the touches
Parameters:-
touches
<Array>
center contains pageX
, pageY
, clientX
and clientY
properties
getDirection
( touch1, touch2
)
src/utils.js:223
do a small comparision to get the direction between two touches.
Parameters:direction matches DIRECTION_LEFT|RIGHT|UP|DOWN
getDistance
( touch1, touch2
)
src/utils.js:241
calculate the distance between two touches
Parameters:distance
getRotation
( start, end
)
src/utils.js:273
calculate the rotation degrees between two touchLists
Parameters:rotation
getScale
( start, end
)
src/utils.js:256
calculate the scale factor between two touchLists no scale is 1, and goes down to 0 when pinched together, and bigger when pinched out
Parameters:scale
getVelocity
( delta_time, delta_x, delta_y
)
src/utils.js:192
calculate the velocity between two points. unit is in px per ms.
Parameters:velocity x
and y
hasParent
( node, parent
)
src/utils.js:134
find if a node is in the given parent
Parameters:-
node
<HTMLElement> -
parent
<HTMLElement>
found
inArray
( src, find
)
src/utils.js:100
find if a array contains the object using indexOf or a simple polyfill
Parameters:inStr
( src, find
)
src/utils.js:88
find if a string contains the string using indexOf
Parameters:found
isVertical
( direction
)
src/utils.js:289
find out if the direction is vertical *
Parameters:-
direction
<String>matches
DIRECTION_UP|DOWN
is_vertical
off
( element, type, handler
)
src/utils.js:40
simple removeEventListener wrapper
Parameters:-
element
<HTMLElement> -
type
<String> -
handler
<Function>
on
( element, type, handler
)
src/utils.js:28
simple addEventListener wrapper
Parameters:-
element
<HTMLElement> -
type
<String> -
handler
<Function>
toArray
( obj
)
src/utils.js:123
convert an array-like object (arguments
, touchlist
) to an array
-
obj
<Object>
toggleBehavior
( element, props, [toggle=false]
)
src/utils.js:300
toggle browser default behavior by setting css properties.
userSelect='none'
also sets element.onselectstart
to false
userDrag='none'
also sets element.ondragstart
to false