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:196
calculate the angle between two coordinates
Parameters:angle
getCenter( touches )
src/utils.js:142
get the center of all the touches
Parameters:-
touches<Array>
center contains pageX, pageY, clientX and clientY properties
getDirection( touch1, touch2 )
src/utils.js:210
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:227
calculate the distance between two touches
Parameters:distance
getRotation( start, end )
src/utils.js:257
calculate the rotation degrees between two touchLists
Parameters:rotation
getScale( start, end )
src/utils.js:241
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( deltaTime, deltaX, deltaY )
src/utils.js:181
calculate the velocity between two points. unit is in px per ms.
Parameters:velocity x and y
hasParent( node, parent )
src/utils.js:125
find if a node is in the given parent
Parameters:-
node<HTMLElement> -
parent<HTMLElement>
found
inArray( src, find )
src/utils.js:94
find if a array contains the object using indexOf or a simple polyfill
Parameters:inStr( src, find )
src/utils.js:83
find if a string contains the string using indexOf
Parameters:found
isVertical( direction )
src/utils.js:272
find out if the direction is vertical *
Parameters:-
direction<String>matches
DIRECTION_UP|DOWN
is_vertical
off( element, type, handler )
src/utils.js:38
simple removeEventListener wrapper
Parameters:-
element<HTMLElement> -
type<String> -
handler<Function>
on( element, type, handler )
src/utils.js:27
simple addEventListener wrapper
Parameters:-
element<HTMLElement> -
type<String> -
handler<Function>
toArray( obj )
src/utils.js:115
convert an array-like object (arguments, touchlist) to an array
-
obj<Object>
toggleBehavior( element, props, [toggle=true] )
src/utils.js:309
toggle browser default behavior by setting css properties.
userSelect='none' also sets element.onselectstart to false
userDrag='none' also sets element.ondragstart to false