API Docs for: 1.1.1

Class Utils

Class defined in: src/utils.js:1
each( obj, iterator, context )
src/utils.js:49

forEach over arrays and objects

Parameters:
Object 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

Parameters:
Returns: <Object>

dest

Number getAngle( touch1, touch2 )
src/utils.js:196

calculate the angle between two coordinates

Parameters:
Returns: <Number>

angle

Object getCenter( touches )
src/utils.js:142

get the center of all the touches

Parameters:
Returns: <Object>

center contains pageX, pageY, clientX and clientY properties

String getDirection( touch1, touch2 )
src/utils.js:210

do a small comparision to get the direction between two touches.

Parameters:
Returns: <String>

direction matches DIRECTION_LEFT|RIGHT|UP|DOWN

Number getDistance( touch1, touch2 )
src/utils.js:227

calculate the distance between two touches

Parameters:
Returns: <Number>

distance

Number getRotation( start, end )
src/utils.js:257

calculate the rotation degrees between two touchLists

Parameters:
  • start <Array>

    array of touches

  • end <Array>

    array of touches


Returns: <Number>

rotation

Number 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:
  • start <Array>

    array of touches

  • end <Array>

    array of touches


Returns: <Number>

scale

Object getVelocity( deltaTime, deltaX, deltaY )
src/utils.js:181

calculate the velocity between two points. unit is in px per ms.

Parameters:
Returns: <Object>

velocity x and y

Boolean hasParent( node, parent )
src/utils.js:125

find if a node is in the given parent

Parameters:
Returns: <Boolean>

found

Boolean | Number inArray( src, find )
src/utils.js:94

find if a array contains the object using indexOf or a simple polyfill

Parameters:
Returns: <Boolean | Number>

false when not found, or the index

Boolean inStr( src, find )
src/utils.js:83

find if a string contains the string using indexOf

Parameters:
Returns: <Boolean>

found

Boolean isVertical( direction )
src/utils.js:272

find out if the direction is vertical *

Parameters:
  • direction <String>

    matches DIRECTION_UP|DOWN


Returns: <Boolean>

is_vertical

off( element, type, handler )
src/utils.js:38

simple removeEventListener wrapper

Parameters:
on( element, type, handler )
src/utils.js:27

simple addEventListener wrapper

Parameters:
Array toArray( obj )
src/utils.js:115

convert an array-like object (arguments, touchlist) to an array

Parameters:
Returns: <Array>
toggleBehavior( element, props, [toggle=false] )
src/utils.js:282

toggle browser default behavior by setting css properties. userSelect='none' also sets element.onselectstart to false userDrag='none' also sets element.ondragstart to false

Parameters: