@danielgindi/dom-utils 1.0.11 → 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 +13 -7
- package/dist/lib.cjs.js +318 -434
- package/dist/lib.cjs.js.map +1 -1
- package/dist/lib.cjs.min.js +2 -2
- package/dist/lib.cjs.min.js.map +1 -1
- package/dist/lib.es6.js +977 -1093
- package/dist/lib.es6.js.map +1 -1
- package/dist/lib.es6.min.js +2 -2
- package/dist/lib.es6.min.js.map +1 -1
- package/dist/lib.umd.js +318 -434
- package/dist/lib.umd.js.map +1 -1
- package/dist/lib.umd.min.js +2 -2
- package/dist/lib.umd.min.js.map +1 -1
- package/dist/types/Css.d.ts +130 -0
- package/dist/types/Dom.d.ts +33 -0
- package/dist/types/DomCompat.d.ts +55 -0
- package/dist/types/DomEventsSink.d.ts +20 -0
- package/dist/types/ScrollHelper.d.ts +39 -0
- package/dist/types/Touches.d.ts +14 -0
- package/dist/types/index.d.ts +7 -0
- package/eslint.config.mjs +47 -111
- package/lib/{Css.js → Css.ts} +448 -434
- package/lib/{Dom.js → Dom.ts} +132 -132
- package/lib/{DomCompat.js → DomCompat.ts} +276 -276
- package/lib/{DomEventsSink.js → DomEventsSink.ts} +70 -68
- package/lib/{ScrollHelper.js → ScrollHelper.ts} +158 -158
- package/lib/{Touches.js → Touches.ts} +84 -84
- package/package.json +28 -17
- package/tsconfig.json +17 -0
- package/tsconfig.scripts.json +10 -0
- package/tsconfig.tests.json +10 -0
- /package/lib/{index.js → index.ts} +0 -0
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
|
|
5
|
+
All functions have JSDoc comments and generated TypeScript declarations.
|
|
6
6
|
|
|
7
|
-
* `lib/Css.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|