redBus strawberry
This is a small utility library which allows to add and remove events , classes and a few other DOM related stuff.
Install
npm install rb-strawberryvar strawberry =
Usage
-
getElementOffset
var offset = strawberry;/* offset = {top : topOffset,left : leftOffset,bottom : bottomOffset,right : rightOffset}*/ -
normalizeEvent
var normalizedEvent = strawberry;This produces an event object that is simliar across all browsers.
-
addClass
strawberry;This adds the class to the element.
-
removeClass
strawberry;This removes the class from the element.
-
hasClass
var isClass = strawberry;returns true if the element has the class else returns false.
-
addEvent
strawberry;//elem is the element on which the event is to be bound//type is the type of event e.g. 'click'//func is the callback for the event//useCapture is boolean for using event capture -
removeEvent
strawberry;//elem is the element on which the event is to be unbound//type is the type of event e.g. 'click'//func is the callback for the event//useCapture is boolean for using event capture -
isChildOf
var test = strawberry;// returns true if elem inside of the parent element else returns false -
removeEvents
strawberry;// removes all the events bound to the element -
debounce
strawberry;//func is a function that will be called after wait number of milliseconds//e.g.strawberry; -
mouseCoords
var mousePos = strawberry;/*mousePos = {x : xPositionOfMouse,y : yPositionOfMouse};*/This function returns the position of the mouse including the scroll position
-
emptyElem
strawberry;Removes all the children of the element