pmx-util-dom
v2.0.0-0
Published
Utility module to provide some basics functions to operate over the DOM
Downloads
15
Readme
PMX Util DOM:
Intro
Utility module to provide some basics functions to operate over the DOM
Getting Started
import { <functionName> } from 'pmx-util-dom';
Where <functionName>
is one of the functions specified under API.
API
__getDirectChilds(parent, selector)
:
Grabs the direct child of a passed parent element
__hasSubmenu(item)
Detects if an item contains a submenu
__getItemLevel({ item, levelIdentifier })
For components using class level identifiers this function will return level number (position within the DOM element)
__getItemAtLevel({ limitParent, levelIdentifier, item, level, type })
returns an element that matches the selector type
that is positioned at the specified level
and it is contained within (child of) limitParent
.
__isFirstDescendant({ item, classSelector })
returns a boolean specifying whether or not the passed item
is the first element within its parent (positioned first).
__isLastDescendant({ item, classSelector })
returns a boolean specifying whether or not the passed item
is the last element within its parent (positioned last).
__isSubmenuOpen(item, activeClass)
return a boolean indicating whether or not the passed item
has its submenu open
__getItemHeight(item)
returns the item
's offsetHeight
__generateUID({ length = 6, namespace })
returns an UID of lenght
characters long using the passed namespace
__closest(fn, limitParent, el, selector)
look up for the closest element that matches the passed selector
and fn
starting from the passed el
that is contained within the boundaries of limitParent
__hasClassName(el, className)
checks if an el
contains the passed className
__closestByClassName
look up for the closest element that matches the passed class selector
starting from the passed el
that is contained within the boundaries of limitParent
Browser Support
- IE 10+
- Chrome
- Firefox
- Safari