# Global

##

### Methods

#### aClass($elements, cssClass)

  Add a class on an element or a list of elements

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `$elements` | HTMLElement | Array.<HTMLElement> | DOM element or array of DOM element
  `cssClass` | String | Array.<string> | Class name, class names separated by space or array of class

  ##### Returns:

  Type
    HTMLElement | Array.<HTMLElement>

  ##### Example

      aClass( $elements, cssClass )

#### append($what, $where)

  Append a DOM element to an other. Require a polyfill.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `$what` | HTMLElement |
  `$where` | HTMLElement |

  ##### Returns:

  - Appened element
  Type
    HTMLElement

  ##### Example

      append( $what, $where )

#### children($element)

  Return all the children of a DOM element

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `$element` | HTMLElement |

  ##### Returns:

  Type
    Array.<HTMLElement>

  ##### Example

      $elements = children($element)

#### clone($element)

  Clone a DOM element

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `$element` | HTMLElement |

  ##### Returns:

  - Cloned element
  Type
    HTMLElement

  ##### Example

      $clonedElement = clone( $element )

#### documentSize()

  Get the current document size

  ##### Returns:

  the width and height of the element
  Type
    documentSize_Object

  ##### Example

      { width, height } = documentSize()

#### filter($elements, selector)

  Filter a DOM list depending on a selector

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `$elements` | Array.<HTMLElement> |
  `selector` | String |

  ##### Returns:

  - Filtered list
  Type
    Array.<HTMLElement>

  ##### Example

      filteredArray = filter( $elements, selector );

#### getCssProperty($element, property)

  Get a CSS property of an element

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `$element` | HTMLElement |
  `property` | String |

  ##### Returns:

  Type
    String

  ##### Example

      value = getCssProperty($element, '--my-var')

#### getMatrix($elem)

  Get the matrix of a DOM element

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `$elem` | HTMLElement |

  ##### Returns:

  - the matrix object
  Type
    matrix_Object

  ##### Example

      { m11, m21, m31, m41, m12, m22, m32, m42, m13, m23, m33, m43, m14, m24, m34, m44 } = getMatrix ( $elem )

#### getStyle($element)

  Return the style of a DOM element

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `$element` | HTMLElement |

  ##### Returns:

  Type
    Object

  ##### Example

      styles = getStyle($element)

#### getTransform($elem)

  Get the transform values of a DOM element

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `$elem` | HTMLElement |

  ##### Returns:

  - the transform properties
  Type
    transform_Object

  ##### Example

      { tx, ty, tz, rx, ry, rz } = getTransform ( $elem )

#### getTranslate($elem)

  Get the translation values of a DOM element

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `$elem` | HTMLElement |

  ##### Returns:

  - the translate properties
  Type
    translate_Object

  ##### Example

      { tx, ty, tz } = getTranslate ( $elem )

#### hClass($element, cssClass)

  Check if a class is present on a DOM element

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `$element` | HTMLElement | DOM element
  `cssClass` | String |

  ##### Returns:

  - true if a class is present on a DOM element
  Type
    boolean

  ##### Example

      boolean = hClass( $element, cssClass )

#### height($element)

  Compute the height of an element

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `$element` | HTMLElement |

  ##### Returns:

  the height of an element
  Type
    Number

  ##### Example

      elementHeight = height( $element )

#### index($element)

  Return the index of a DOM element

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `$element` | HTMLElement |

  ##### Returns:

  - Position (starting at 0) of the element in the DOM list is belong to.
  Type
    Number

  ##### Example

      elementIndex = index( $element );

#### insertAfter($what, $where)

  Insert a DOM element after an other

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `$what` | HTMLElement |
  `$where` | HTMLElement |

  ##### Returns:

  - Inserted element
  Type
    HTMLElement

  ##### Example

      insertAfter( $what, $where )

#### insertBefore($what, $where)

  Insert a DOM element before an other

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `$what` | HTMLElement |
  `$where` | HTMLElement |

  ##### Returns:

  - Inserted element
  Type
    HTMLElement

  ##### Example

      insertBefore( $what, $where )

#### next($element)

  Return the next element in the DOM

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `$element` | HTMLElement |

  ##### Returns:

  Type
    HTMLElement

  ##### Example

      $nextElement = next($element)

#### offset($element, isRelativeToViewport, $relativeTo)

  Get the transform values of a DOM element

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `$element` | HTMLElement |
  `isRelativeToViewport` | Boolean | If true, the position is computed relatively to the viewport (top/left of the browser) and not the top/left of the document. This mean, it doesn't take the scroll in count.
  `$relativeTo` | HTMLElement | Optional, compute top and left relatively to another Element

  ##### Returns:

  - the offset properties
  Type
    offset_Object

  ##### Example

      // Get offset from the top/left of the document
      { width, height, top, left, bottom, right } = offset( $element )

      // Same without taking the scroll position in count (top/left of the browser).
      result = offset( $element, true )

      // Get offset relatively from another element
      result = offset( $element, false, $target )

#### outerHeight($element, border, margin)

  Get the outside height of a DOM element

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `$element` | HTMLElement |
  `border` | Boolean | border Include border width?
  `margin` | Boolean | margin Include margin width?

  ##### Returns:

  - the height of the object
  Type
    Number

  ##### Example

      // height including padding
      elementHeight = outerHeight($element)

      // height including padding, border and margin
      elementHeight = outerHeight($element, true, true)

#### outerSize($element, border, margin)

  Get the outside size of a DOM element

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `$element` | HTMLElement |
  `border` | Boolean | Include border width?
  `margin` | Boolean | Include margin width?

  ##### Returns:

  - the width and height of the object
  Type
    outerSize_Object

  ##### Example

      // size including padding
      {width, height} = outerSize($element)

      // height including padding, border and margin
      size = outerSize($element, true, true)

#### outerWidth($element, border, margin)

  Get the outside width of a DOM element

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `$element` | HTMLElement |
  `border` | Boolean | Include border width?
  `margin` | Boolean | Include margin width?

  ##### Returns:

  - the width of the object
  Type
    Number

  ##### Example

      // width including padding
      elementWidth = outerWidth($element)

      // width including padding, border and margin
      elementWidth = outerWidth($element, true, true)

#### pageToDOM(html)

  Convert a whole HTML page string in a document

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `html` | String |

  ##### Returns:

  - a Promise with the converted document in parameter
  Type
    Promise

  ##### Example

      pageToDOM( html ).then( $document => {} )

#### position($element [, $target])

  Return the position of an element or The position relative to another element

  ##### Parameters:

  Name | Type | Argument | Description
  --- | --- | --- | ---
  `$element` | HTMLElement |  |
  `$target` | HTMLElement | <optional> |

  ##### Returns:

  - the coordinate of the object
  Type
    position_Object

  ##### Examples

      { top, left } = position( $element )

      { top, left } = position( $element, $target )

#### prepend($what, $where)

  Prepend a DOM element to an other. Require a polyfill.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `$what` | HTMLElement |
  `$where` | HTMLElement |

  ##### Returns:

  - Prepened element
  Type
    HTMLElement

  ##### Example

      prepend( $what, $where )

#### previous($element)

  Return the previous element in the DOM

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `$element` | HTMLElement |

  ##### Returns:

  Type
    HTMLElement

  ##### Example

      $previousElement = previous($element)

#### prop($element, property)

  Return the value of a style property of a DOM element

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `$element` | HTMLElement |
  `property` | String |

  ##### Returns:

  Type
    String

  ##### Example

      styles = prop($element, 'marginTop')

#### rClass($elements, cssClass)

  Remove a class on an element or a list of elements

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `$elements` | HTMLElement | Array.<HTMLElement> | DOM element or array of DOM element
  `cssClass` | String | Array.<String> | Class name, class names separated by space or array of class

  ##### Returns:

  Type
    HTMLElement | Array.<HTMLElement>

  ##### Example

      rClass( $elements, cssClass )

#### remove($element, $parent)

  Remove an element from the DOM

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `$element` | HTMLElement |
  `$parent` | HTMLElement | If undefined the parentNode will be used

  ##### Returns:

  - Removed element
  Type
    HTMLElement

  ##### Example

      remove( $element )
      remove( $element, $parent )

#### sClass($elements, oldCssClass, newCssClass)

  Replace classes. Remove oldCssClass and add newCssClass only if oldCssClass exists

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `$elements` | HTMLElement | Array.<HTMLElement> |
  `oldCssClass` | String |
  `newCssClass` | String |

  ##### Returns:

  Type
    HTMLElement | Array.<HTMLElement>

  ##### Example

      sClass( $elements, oldCssClass, newCssClass )

#### setCssProperty($element, property, value)

  Set a CSS property on an element

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `$element` | HTMLElement |
  `property` | String | Object |
  `value` | String |

  ##### Returns:

  Type
    HTMLElement

  ##### Example

      $element = setCssVar($element, '--my-var', '12px')
      $element = setCssVar($element, {
       "--my-var":   "12px",
       "--my-var-2": "100%"
      })

#### size($element)

  Compute the size of an element

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `$element` | HTMLElement |

  ##### Returns:

  - the width and height of an element
  Type
    size_Object

  ##### Example

      {width, height} = size( $element )

#### strToDOM(html [, tag])

  Convert an html string into a DOM object

  ##### Parameters:

  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `html` | String |  |  |
  `tag` | String | <optional> | "DIV" | Used to create an element to convert html inside. 'DIV' by default

  ##### Returns:

  - The created DOM element
  Type
    HTMLElement

  ##### Example

      $element = strToDOM( html );

      // Use of tag parameter
      $li = strToDOM( '<li></li>', 'UL' );

#### tClass($elements, cssClass [, forceAdd])

  Toggle a class on an element or a list of elements

  ##### Parameters:

  Name | Type | Argument | Description
  --- | --- | --- | ---
  `$elements` | HTMLElement | Array.<HTMLElement> |  | DOM element or array of DOM element
  `cssClass` | String | Array.<String> |  | Class name, class names separated by space or array of class
  `forceAdd` | Boolean | <optional> |

  ##### Returns:

  Type
    HTMLElement | Array.<HTMLElement>

  ##### Example

      tClass( $elements, cssClass )
      tClass( $elements, cssClass, forceAdd )

#### width($element)

  Compute the width of an element

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `$element` | HTMLElement |

  ##### Returns:

  the width of an element
  Type
    Number

  ##### Example

      elementWidth = width( $element )

#### windowScroll()

  Get the scroll position of the window

  ##### Returns:

  - the position of the scroll
  Type
    windowScroll_Object

  ##### Example

      {top, left} = scroll()

#### windowSize()

  Get the size of the window

  ##### Returns:

  - the width and height of the window
  Type
    windowSizeObject

  ##### Example

      {width, height} = windowSize()

#### wrap($element, tag)

  Wrap a DOM element in another

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `$element` | HTMLElement |
  `tag` | String | HTMLElement | String example:

  ##### Returns:

  - The wrap element
  Type
    HTMLElement

  ##### Example

      $wrapper = wrap( $element, '<span class="abc"></span>' );

### Type Definitions

#### documentSize_Object

  ##### Type:

  - Object

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `width` | Number |
  `height` | Number |

#### matrix_Object

  ##### Type:

  - Object

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `m11` | Number |
  `m21` | Number |
  `m31` | Number |
  `m41` | Number |
  `m12` | Number |
  `m22` | Number |
  `m32` | Number |
  `m42` | Number |
  `m13` | Number |
  `m23` | Number |
  `m33` | Number |
  `m43` | Number |
  `m14` | Number |
  `m24` | Number |
  `m34` | Number |
  `m44` | Number |

#### offset_Object

  ##### Type:

  - object

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `top` | Number |
  `left` | Number |
  `right` | Number |
  `bottom` | Number |
  `width` | Number |
  `height` | Number |

#### outerSize_Object

  ##### Type:

  - Object

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `width` | Number |
  `height` | Number |

#### position_Object

  ##### Type:

  - Object

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `top` | Number |
  `left` | Number |

#### size_Object

  ##### Type:

  - Object

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `width` | Number |
  `height` | Number |

#### transform_Object

  ##### Type:

  - Object

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `tx` | Number |
  `ty` | Number |
  `tz` | Number |
  `rx` | Number |
  `ry` | Number |
  `rz` | Number |

#### translate_Object

  ##### Type:

  - Object

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `tx` | Number |
  `ty` | Number |
  `tz` | Number |

#### windowScroll_Object

  ##### Type:

  - Object

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `top` | Number |
  `left` | Number |

#### windowSizeObject

  ##### Type:

  - Object

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `width` | Number |
  `height` | Number |

#### Search results