HelperFunctions

Methods

static addMouseScrollEventListener(query, func)

add a cross browser event listener on a mouse scroll

Parameters:
Name Type Description
query string

DOM query of the element that the listener will be added to

func function

Function that will be called when the event occurs. The function takes as a parameter an event object.

static getJSONString(data, prettyopt, dataUriopt) → {string}

convert a data object to JSON string or to a data URI containing a JSON string

Parameters:
Name Type Attributes Default Description
data Object

object that will be serialized into a JSON string

pretty Boolean <optional>
false

if true, the code will be proprerly indented, else a more compact syntax will be used

dataUri Boolean <optional>
false

return dataUri containing the JSON string instead of the pure JSON string

Returns:
string

static manhattanDistance(a, b) → {number}

returns the Manhattan distance between the points a and b

Parameters:
Name Type Description
a Object

object containing numeric attributes x and y

b Object

object containing numeric attributes x and y

Returns:
number