Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@danielgindi/dom-utils
Advanced tools
Readme
A collection of dom utilities. So you can work natively with the dom without dom frameworks.
All functions have appropriate JSDocs.
lib/Css.js
: A set of css helpers
getCssProps(el: Element, props: string[]): Object<string, string>
setCssProps(el: ElementCSSInlineStyle, props: Object<string, string>)
getElementWidth(el: Element, paddings: boolean = false, borders: boolean = false, margins: boolean = false): number
getElementHeight(el: Element, paddings: boolean = false, borders: boolean = false, margins: boolean = false): number
getPseudoElementWidth(el: Element, pseudo: string, paddings: boolean = false, borders: boolean = false, margins: boolean = false): number
getPseudoElementHeight(el: Element, pseudo: string, paddings: boolean = false, borders: boolean = false, margins: boolean = false): number
setElementWidth(el: Element, value: number, paddings: boolean = false, borders: boolean = false, margins: boolean = false)
setElementHeight(el: Element, value: number, paddings: boolean = false, borders: boolean = false, margins: boolean = false)
getElementOffset(el: Element): {top: number, left: number}
anchoredPosition(el: Element, xSpec: 'left'|'center'|'right'|'start'|'end'|string|number, ySpec: 'top'|'center'|'bottom'|string|number, size: {width: number: height: number}, rtl?: boolean): {left: number, top: number, right: number, bottom: number, xSpec: string|number, ySpec: string|number}
lib/Dom.js
: A set of dom helpers
createElement(tag: tag, attrs: Object<string, string>, children: Node|Node[]): Element
setElementAttrs(el: Element, attrs: Object<string, string>)
closestUntil(el: Element, selector: string, until?: Node): Node|null
prev(el: Element, selector: string): Element|null
next(el: Element, selector: string): Element|null
lib/DomCompat.js
: A set of compatibility functions, for several functions which are not available on all browsers
getRootNode(el: Node): Node|null
closest(el: Element, selector: string):Node|null
remove(el: Element)
before(before: ChildNode, ...nodes: (Node|string)[])
after(after: ChildNode, ...nodes: (Node|string)[])
prepend(parent: ParentNode, ...nodes: (Node|string)[])
append(parent: ParentNode, ...nodes: (Node|string)[])
scopedSelector(el: Element, selector: Element): Element|null
scopedSelectorAll(el: Element, selector: Element): NodeListOf<Element>
toggleClass(el: Element, className: string, toggle?: boolean): boolean
lib/DomEventsSink.js
: A class for registering/unregistering event listeners
add(el: EventTarget, eventName: string, handler: EventListenerOrEventListenerObject, optionsOrCapture?: boolean|AddEventListenerOptions): DomEventsSink
'event.namespace'
.remove(el?: EventTarget, eventName?: string, handler?: EventListenerOrEventListenerObject, optionsOrCapture?: boolean|AddEventListenerOptions): DomEventsSink
Touches.js
: Touch helpers
bindTouchTap(el: Element, options: { distance: number = 9, handler: function(event: TouchEvent) }): { unbind: Function }
ScrollHelper.js
: scroll helpers
getScrollLeft
/setScrollLeft
to normalize the behavior of scrollLeft
across the quirks of different browsers.getScrollHorz
/setScrollHorz
to record and restore scrollLeft
positions on RTL elements, or to switch between ltr/rtl modes without loosing scroll position.calculateNativeScrollLeftForLeft(el: Element, left: number, rtl?: boolean|undefined): number
scrollLeft
value for the specific element in the current browser.scrollLeft
value (taken with getScrollLeft
).setScrollLeft
if you want to animate to this value, or other kinds of manipulation.
rtl
is optional, you can pass it if you already have the 'direction' of the element and want to avoid that extra calculation.getScrollLeft(el: Element, rtl?: boolean|undefined): number
scrollLeft
value from an element, and normalizes across the different scroll methods to a unified method.setScrollLeft
to set a value back to the element.rtl
is optional, you can pass it if you already have the 'direction' of the element and want to avoid that extra calculation.setScrollLeft(el: Element, value: number, rtl?: boolean|undefined)
scrollLeft
on an element.rtl
is optional, you can pass it if you already have the 'direction' of the element and want to avoid that extra calculation.calculateNativeScrollLeftForLeft(...)
to calculate the native scrollLeft
.calculateNativeScrollLeftForHorz(el: Element, left: number, rtl?: boolean|undefined): number
scrollLeft
value for an element, from an rtl-aware scrollLeft
(i.e from getScrollHorz()
).
You will use this function instead of setScrollHorz
if you want to animate to this value, or other kinds of manipulation.
rtl
is optional, you can pass it if you already have the 'direction' of the element and want to avoid that extra calculation.getScrollHorz(el: Element, rtl?: boolean|undefined): number
scrollLeft
value from an element. The value will behave like a standard scrollLeft
,
except that for an rtl element it will have an rtl meaning, instead of being some crazy number.rtl
is optional, you can pass it if you already have the 'direction' of the element and want to avoid that extra calculation.setScrollHorz(el: Element, value: number, rtl?: boolean|undefined)
scrollLeft
on an element, with an rtl-aware value.rtl
is optional, you can pass it if you already have the 'direction' of the element and want to avoid that extra calculation.calculateNativeScrollLeftForHorz(...)
to calculate the native scrollLeft
.If you want to help, you could:
All the code here is under MIT license. Which means you could do virtually anything with the code. I will appreciate it very much if you keep an attribution where appropriate.
The MIT License (MIT)
Copyright (c) 2013 Daniel Cohen Gindi (danielgindi@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
FAQs
A collection of dom utilities. So you can work natively with the dom without dom frameworks.
The npm package @danielgindi/dom-utils receives a total of 6 weekly downloads. As such, @danielgindi/dom-utils popularity was classified as not popular.
We found that @danielgindi/dom-utils demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.