@danielgindi/dom-utils 1.0.10 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  A collection of dom utilities. So you can work natively with the dom without dom frameworks.
4
4
 
5
- All functions have appropriate JSDocs.
5
+ All functions have JSDoc comments and generated TypeScript declarations.
6
6
 
7
- * `lib/Css.js`: A set of css helpers
7
+ * `lib/Css.ts`: A set of css helpers
8
8
  * `getCssProps(el: Element, props: string[]): Object<string, string>`
9
9
  * `setCssProps(el: ElementCSSInlineStyle, props: Object<string, string>)`
10
10
  * `getElementWidth(el: Element, paddings: boolean = false, borders: boolean = false, margins: boolean = false): number`
@@ -16,14 +16,14 @@ All functions have appropriate JSDocs.
16
16
  * `getElementOffset(el: Element): {top: number, left: number}`
17
17
  * `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}`
18
18
 
19
- * `lib/Dom.js`: A set of dom helpers
19
+ * `lib/Dom.ts`: A set of dom helpers
20
20
  * `createElement(tag: tag, attrs: Object<string, string>, children: Node|Node[]): Element`
21
21
  * `setElementAttrs(el: Element, attrs: Object<string, string>)`
22
22
  * `closestUntil(el: Element, selector: string, until?: Node): Node|null`
23
23
  * `prev(el: Element, selector: string): Element|null`
24
24
  * `next(el: Element, selector: string): Element|null`
25
25
 
26
- * `lib/DomCompat.js`: A set of compatibility functions, for several functions which are not available on all browsers
26
+ * `lib/DomCompat.ts`: A set of compatibility functions, for several functions which are not available on all browsers
27
27
  * `getRootNode(el: Node): Node|null`
28
28
  * `closest(el: Element, selector: string):Node|null`
29
29
  * `remove(el: Element)`
@@ -35,17 +35,17 @@ All functions have appropriate JSDocs.
35
35
  * `scopedSelectorAll(el: Element, selector: Element): NodeListOf<Element>`
36
36
  * `toggleClass(el: Element, className: string, toggle?: boolean): boolean`
37
37
 
38
- * `lib/DomEventsSink.js`: A class for registering/unregistering event listeners
38
+ * `lib/DomEventsSink.ts`: A class for registering/unregistering event listeners
39
39
  * `add(el: EventTarget, eventName: string, handler: EventListenerOrEventListenerObject, optionsOrCapture?: boolean|AddEventListenerOptions): DomEventsSink`
40
40
  event names support namespacing, where `'event.namespace'`.
41
41
  * `remove(el?: EventTarget, eventName?: string, handler?: EventListenerOrEventListenerObject, optionsOrCapture?: boolean|AddEventListenerOptions): DomEventsSink`
42
42
  specify any argument as a filter for what to remove. specify '.namespace' event name in order to remove everything for a specific namespace.
43
43
 
44
- * `Touches.js`: Touch helpers
44
+ * `Touches.ts`: Touch helpers
45
45
  * `bindTouchTap(el: Element, options: { distance: number = 9, handler: function(event: TouchEvent) }): { unbind: Function }`
46
46
  This little function will manage touch events to detect a single tap.
47
47
 
48
- * `ScrollHelper.js`: scroll helpers
48
+ * `ScrollHelper.ts`: scroll helpers
49
49
  * You can use `getScrollLeft`/`setScrollLeft` to normalize the behavior of `scrollLeft` across the quirks of different browsers.
50
50
  * You can use `getScrollHorz`/`setScrollHorz` to record and restore `scrollLeft` positions on RTL elements, or to switch between ltr/rtl modes without loosing scroll position.
51
51
  * `calculateNativeScrollLeftForLeft(el: Element, left: number, rtl?: boolean|undefined): number`
@@ -76,6 +76,12 @@ All functions have appropriate JSDocs.
76
76
 
77
77
  ---
78
78
 
79
+ ## Tests
80
+
81
+ Run `npm test` after `npm install`. The suite covers DOM manipulation, CSS measurements, event listeners, touch gestures, and LTR/RTL scrolling with jsdom.
82
+
83
+ ---
84
+
79
85
  ## Me
80
86
  * Hi! I am Daniel Cohen Gindi. Or in short- Daniel.
81
87
  * danielgindi@gmail.com is my email address.