@koine/dom 1.0.80

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.
Files changed (126) hide show
  1. package/$$.d.ts +10 -0
  2. package/$$.js +12 -0
  3. package/$.d.ts +13 -0
  4. package/$.js +15 -0
  5. package/$each.d.ts +11 -0
  6. package/$each.js +17 -0
  7. package/README.md +1 -0
  8. package/_listen-delegation.d.ts +38 -0
  9. package/_listen-delegation.js +83 -0
  10. package/addClass.d.ts +5 -0
  11. package/addClass.js +15 -0
  12. package/calculateFixedOffset.d.ts +2 -0
  13. package/calculateFixedOffset.js +10 -0
  14. package/createElement.d.ts +9 -0
  15. package/createElement.js +16 -0
  16. package/emitEvent.d.ts +5 -0
  17. package/emitEvent.js +14 -0
  18. package/escapeSelector.d.ts +8 -0
  19. package/escapeSelector.js +10 -0
  20. package/exists.d.ts +7 -0
  21. package/exists.js +12 -0
  22. package/forEach.d.ts +9 -0
  23. package/forEach.js +13 -0
  24. package/getDataAttr.d.ts +8 -0
  25. package/getDataAttr.js +13 -0
  26. package/getDocumentHeight.d.ts +7 -0
  27. package/getDocumentHeight.js +10 -0
  28. package/getHeight.d.ts +5 -0
  29. package/getHeight.js +7 -0
  30. package/getListeners.d.ts +9 -0
  31. package/getListeners.js +18 -0
  32. package/getOffset.d.ts +11 -0
  33. package/getOffset.js +18 -0
  34. package/getOffsetTop.d.ts +10 -0
  35. package/getOffsetTop.js +20 -0
  36. package/getScrollbarWidth.d.ts +5 -0
  37. package/getScrollbarWidth.js +7 -0
  38. package/getStyleValue.d.ts +8 -0
  39. package/getStyleValue.js +10 -0
  40. package/index.d.ts +40 -0
  41. package/index.js +40 -0
  42. package/injectCss.d.ts +5 -0
  43. package/injectCss.js +16 -0
  44. package/isHidden.d.ts +5 -0
  45. package/isHidden.js +7 -0
  46. package/isInViewport.d.ts +10 -0
  47. package/isInViewport.js +18 -0
  48. package/isNodeList.d.ts +7 -0
  49. package/isNodeList.js +14 -0
  50. package/isTotallyScrolled.d.ts +8 -0
  51. package/isTotallyScrolled.js +10 -0
  52. package/listen.d.ts +12 -0
  53. package/listen.js +32 -0
  54. package/listenLoaded.d.ts +7 -0
  55. package/listenLoaded.js +11 -0
  56. package/listenOnce.d.ts +12 -0
  57. package/listenOnce.js +20 -0
  58. package/listenResize.d.ts +8 -0
  59. package/listenResize.js +25 -0
  60. package/listenScroll.d.ts +8 -0
  61. package/listenScroll.js +28 -0
  62. package/node/$$.js +16 -0
  63. package/node/$.js +19 -0
  64. package/node/$each.js +22 -0
  65. package/node/_listen-delegation.js +89 -0
  66. package/node/addClass.js +19 -0
  67. package/node/calculateFixedOffset.js +14 -0
  68. package/node/createElement.js +21 -0
  69. package/node/emitEvent.js +18 -0
  70. package/node/escapeSelector.js +14 -0
  71. package/node/exists.js +16 -0
  72. package/node/forEach.js +17 -0
  73. package/node/getDataAttr.js +17 -0
  74. package/node/getDocumentHeight.js +14 -0
  75. package/node/getHeight.js +11 -0
  76. package/node/getListeners.js +22 -0
  77. package/node/getOffset.js +22 -0
  78. package/node/getOffsetTop.js +24 -0
  79. package/node/getScrollbarWidth.js +11 -0
  80. package/node/getStyleValue.js +14 -0
  81. package/node/index.js +43 -0
  82. package/node/injectCss.js +20 -0
  83. package/node/isHidden.js +11 -0
  84. package/node/isInViewport.js +22 -0
  85. package/node/isNodeList.js +18 -0
  86. package/node/isTotallyScrolled.js +14 -0
  87. package/node/listen.js +36 -0
  88. package/node/listenLoaded.js +15 -0
  89. package/node/listenOnce.js +24 -0
  90. package/node/listenResize.js +29 -0
  91. package/node/listenScroll.js +32 -0
  92. package/node/off.js +19 -0
  93. package/node/on.js +19 -0
  94. package/node/onClickOutside.js +21 -0
  95. package/node/once.js +20 -0
  96. package/node/removeClass.js +19 -0
  97. package/node/scrollTo.js +32 -0
  98. package/node/setDataAttr.js +22 -0
  99. package/node/setVendorCSS.js +25 -0
  100. package/node/siblings.js +23 -0
  101. package/node/toArray.js +13 -0
  102. package/node/unlisten.js +37 -0
  103. package/off.d.ts +5 -0
  104. package/off.js +15 -0
  105. package/on.d.ts +5 -0
  106. package/on.js +15 -0
  107. package/onClickOutside.d.ts +1 -0
  108. package/onClickOutside.js +17 -0
  109. package/once.d.ts +6 -0
  110. package/once.js +15 -0
  111. package/package.json +16 -0
  112. package/removeClass.d.ts +5 -0
  113. package/removeClass.js +15 -0
  114. package/scrollTo.d.ts +10 -0
  115. package/scrollTo.js +28 -0
  116. package/setDataAttr.d.ts +9 -0
  117. package/setDataAttr.js +18 -0
  118. package/setVendorCSS.d.ts +9 -0
  119. package/setVendorCSS.js +21 -0
  120. package/siblings.d.ts +7 -0
  121. package/siblings.js +19 -0
  122. package/toArray.d.ts +7 -0
  123. package/toArray.js +9 -0
  124. package/typings.d.ts +0 -0
  125. package/unlisten.d.ts +12 -0
  126. package/unlisten.js +33 -0
package/$$.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Sizzle/jQuery like DOM nodes shortcut for `document.querySelectorAll`
3
+ * To avoid an extra function call we inline the above `escape`
4
+ *
5
+ * @param string selector DOM selector
6
+ * @param parent It falls back to `window.document`
7
+ * @param avoidEscape Whether to avoid escaping `:` in the selector string
8
+ */
9
+ export declare function $$<T extends Element = HTMLElement>(selector: string, parent?: HTMLElement | Document, avoidEscape?: boolean): NodeListOf<T>;
10
+ export default $$;
package/$$.js ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Sizzle/jQuery like DOM nodes shortcut for `document.querySelectorAll`
3
+ * To avoid an extra function call we inline the above `escape`
4
+ *
5
+ * @param string selector DOM selector
6
+ * @param parent It falls back to `window.document`
7
+ * @param avoidEscape Whether to avoid escaping `:` in the selector string
8
+ */
9
+ export function $$(selector, parent, avoidEscape) {
10
+ return (parent ? parent : document).querySelectorAll(avoidEscape ? selector : selector.replace(/:/g, "\\:"));
11
+ }
12
+ export default $$;
package/$.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Sizzle/jQuery like DOM nodes shortcut for `document.querySelector`
3
+ * To avoid an extra function call we inline the above `escape`
4
+ *
5
+ * @param selector DOM selector
6
+ * @param parent It falls back to `window.document`
7
+ * @param avoidEscape Whether to avoid escaping `:` in the selector string
8
+ * @example <caption>Basic DOM selection</caption>
9
+ * const $container = $(".my-section:");
10
+ * const $el = $("[data-some-attr]", $container);
11
+ */
12
+ export declare function $<T extends Element = HTMLElement>(selector: string, parent?: HTMLElement | Document, avoidEscape?: boolean): T;
13
+ export default $;
package/$.js ADDED
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Sizzle/jQuery like DOM nodes shortcut for `document.querySelector`
3
+ * To avoid an extra function call we inline the above `escape`
4
+ *
5
+ * @param selector DOM selector
6
+ * @param parent It falls back to `window.document`
7
+ * @param avoidEscape Whether to avoid escaping `:` in the selector string
8
+ * @example <caption>Basic DOM selection</caption>
9
+ * const $container = $(".my-section:");
10
+ * const $el = $("[data-some-attr]", $container);
11
+ */
12
+ export function $(selector, parent, avoidEscape) {
13
+ return (parent ? parent : document).querySelector(avoidEscape ? selector : selector.replace(/:/g, "\\:"));
14
+ }
15
+ export default $;
package/$each.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Each shortcut, iterate through a NodeList of HTMLElements retrieved with the
3
+ * given selector (and optionally a parent container passed as thrid arguement)
4
+ *
5
+ * @param selector DOM selector
6
+ * @param callback
7
+ * @param parent It falls back to `window.document`
8
+ * @param scope
9
+ */
10
+ export declare function $each<T extends Element = HTMLElement>(selector: string, callback: ($element: T, index: number) => any, parent?: HTMLElement, scope?: object): void;
11
+ export default $each;
package/$each.js ADDED
@@ -0,0 +1,17 @@
1
+ import $$ from "./$$";
2
+ /**
3
+ * Each shortcut, iterate through a NodeList of HTMLElements retrieved with the
4
+ * given selector (and optionally a parent container passed as thrid arguement)
5
+ *
6
+ * @param selector DOM selector
7
+ * @param callback
8
+ * @param parent It falls back to `window.document`
9
+ * @param scope
10
+ */
11
+ export function $each(selector, callback, parent, scope) {
12
+ var nodes = $$(selector, parent);
13
+ for (var i = 0; i < nodes.length; i++) {
14
+ callback.call(scope, nodes[i], i);
15
+ }
16
+ }
17
+ export default $each;
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # @koine/dom
@@ -0,0 +1,38 @@
1
+ /**
2
+ * @internal
3
+ */
4
+ export declare type EventCallback = (event: Event, desiredTarget: Window | Document | Element) => any;
5
+ /**
6
+ * @internal
7
+ */
8
+ export declare type ListenEvent = {
9
+ selector: string;
10
+ callback: EventCallback;
11
+ };
12
+ /**
13
+ * Active events
14
+ *
15
+ * @internal
16
+ */
17
+ export declare const activeEvents: Record<Event["type"], ListenEvent[]>;
18
+ /**
19
+ * Get the index for the listener
20
+ *
21
+ * @internal
22
+ */
23
+ export declare function getIndex(arr: ListenEvent[], selector: string, callback: EventCallback): number;
24
+ /**
25
+ * Check if the listener callback should run or not
26
+ *
27
+ * @internal
28
+ * @param target The event.target
29
+ * @param selector The selector/element to check the target against
30
+ * @return If not false, run listener and pass the targeted element to use in the callback
31
+ */
32
+ export declare function getRunTarget(target: Element, selector: string | Window | Document | Element): false | Element | Document | Window | null;
33
+ /**
34
+ * Handle listeners after event fires
35
+ *
36
+ * @internal
37
+ */
38
+ export declare function eventHandler(event: Event): void;
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Listen: events delegation system
3
+ *
4
+ * From:
5
+ * https://github.com/cferdinandi/events
6
+ * https://github.com/cferdinandi/events/blob/master/src/js/events/events.js
7
+ *
8
+ * @fileoverview
9
+ */
10
+ import { isString } from "@koine/utils";
11
+ import { escapeSelector } from "./escapeSelector";
12
+ /**
13
+ * Active events
14
+ *
15
+ * @internal
16
+ */
17
+ export var activeEvents = {};
18
+ /**
19
+ * Get the index for the listener
20
+ *
21
+ * @internal
22
+ */
23
+ export function getIndex(arr, selector, callback) {
24
+ for (var i = 0; i < arr.length; i++) {
25
+ if (arr[i].selector === selector &&
26
+ arr[i].callback.toString() === callback.toString())
27
+ return i;
28
+ }
29
+ return -1;
30
+ }
31
+ /**
32
+ * Check if the listener callback should run or not
33
+ *
34
+ * @internal
35
+ * @param target The event.target
36
+ * @param selector The selector/element to check the target against
37
+ * @return If not false, run listener and pass the targeted element to use in the callback
38
+ */
39
+ export function getRunTarget(target, selector) {
40
+ // @ts-expect-error FIXME: type
41
+ if (["*", "window", window].includes(selector)) {
42
+ return window;
43
+ }
44
+ if ([
45
+ "document",
46
+ "document.documentElement",
47
+ document,
48
+ document.documentElement,
49
+ // @ts-expect-error FIXME: type
50
+ ].includes(selector))
51
+ return document;
52
+ if (isString(selector)) {
53
+ return target.closest(escapeSelector(selector));
54
+ }
55
+ // @ts-expect-error FIXME: type
56
+ if (typeof selector !== "string" && selector.contains) {
57
+ if (selector === target) {
58
+ return target;
59
+ }
60
+ // @ts-expect-error FIXME: type
61
+ if (selector.contains(target)) {
62
+ return selector;
63
+ }
64
+ return false;
65
+ }
66
+ return false;
67
+ }
68
+ /**
69
+ * Handle listeners after event fires
70
+ *
71
+ * @internal
72
+ */
73
+ export function eventHandler(event) {
74
+ if (!activeEvents[event.type])
75
+ return;
76
+ activeEvents[event.type].forEach(function (listener) {
77
+ var target = getRunTarget(event.target, listener.selector);
78
+ if (!target) {
79
+ return;
80
+ }
81
+ listener.callback(event, target);
82
+ });
83
+ }
package/addClass.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Add class shortcut
3
+ */
4
+ export declare function addClass<T extends Element = HTMLElement>(el?: T, className?: string): void;
5
+ export default addClass;
package/addClass.js ADDED
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Add class shortcut
3
+ */
4
+ export function addClass(el, className) {
5
+ if (className === void 0) { className = ""; }
6
+ if (process.env["NODE_ENV"] !== "production") {
7
+ if (!el) {
8
+ console.warn("[@koine/dom:addClass] unexisting DOM element");
9
+ return;
10
+ }
11
+ }
12
+ if (el)
13
+ el.classList.add(className);
14
+ }
15
+ export default addClass;
@@ -0,0 +1,2 @@
1
+ export declare function calculateFixedOffset(selector?: string): number;
2
+ export default calculateFixedOffset;
@@ -0,0 +1,10 @@
1
+ import { $each } from "./$each";
2
+ export function calculateFixedOffset(selector) {
3
+ if (selector === void 0) { selector = "[data-fixed]"; }
4
+ var fixedOffset = 0;
5
+ $each(selector, function ($el) {
6
+ fixedOffset += $el.offsetHeight;
7
+ });
8
+ return fixedOffset;
9
+ }
10
+ export default calculateFixedOffset;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Shortcut for `document.createElement`, allowing to to create an HTML element
3
+ * with a given className directly (a very common use case)
4
+ *
5
+ * @param type
6
+ * @param className
7
+ */
8
+ export declare function createElement(type: string, className?: string): HTMLElement;
9
+ export default createElement;
@@ -0,0 +1,16 @@
1
+ import addClass from "./addClass";
2
+ /**
3
+ * Shortcut for `document.createElement`, allowing to to create an HTML element
4
+ * with a given className directly (a very common use case)
5
+ *
6
+ * @param type
7
+ * @param className
8
+ */
9
+ export function createElement(type, className) {
10
+ var el = document.createElement(type);
11
+ if (className) {
12
+ addClass(el, className);
13
+ }
14
+ return el;
15
+ }
16
+ export default createElement;
package/emitEvent.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Emit event (use only if the targeted browser supports `CustomEvent`s)
3
+ */
4
+ export declare function emitEvent(type?: string, detail?: {}): void;
5
+ export default emitEvent;
package/emitEvent.js ADDED
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Emit event (use only if the targeted browser supports `CustomEvent`s)
3
+ */
4
+ export function emitEvent(type, detail) {
5
+ if (type === void 0) { type = "customEvent"; }
6
+ if (detail === void 0) { detail = {}; }
7
+ if (typeof window.CustomEvent !== "function")
8
+ return;
9
+ document.dispatchEvent(new CustomEvent(type, {
10
+ bubbles: true,
11
+ detail: detail,
12
+ }));
13
+ }
14
+ export default emitEvent;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Escape colons to allow use class names as `.module:block__element`
3
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector#Escaping_special_characters
4
+ *
5
+ * @param selector
6
+ */
7
+ export declare function escapeSelector(selector: string): string;
8
+ export default escapeSelector;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Escape colons to allow use class names as `.module:block__element`
3
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector#Escaping_special_characters
4
+ *
5
+ * @param selector
6
+ */
7
+ export function escapeSelector(selector) {
8
+ return selector.replace(/:/g, "\\:");
9
+ }
10
+ export default escapeSelector;
package/exists.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Checks if passed node exist and is a valid element.
3
+ *
4
+ * @borrows @glidejs/glide/src/utils/dom (source)
5
+ */
6
+ export declare function exists(node?: Element): boolean;
7
+ export default exists;
package/exists.js ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Checks if passed node exist and is a valid element.
3
+ *
4
+ * @borrows @glidejs/glide/src/utils/dom (source)
5
+ */
6
+ export function exists(node) {
7
+ if (node && node instanceof window.HTMLElement) {
8
+ return true;
9
+ }
10
+ return false;
11
+ }
12
+ export default exists;
package/forEach.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ /**
2
+ * For each, iterate through a NodeList of HTMLElements
3
+ *
4
+ * @param nodes DOM nodes collection
5
+ * @param callback
6
+ * @param scope
7
+ */
8
+ export declare function forEach<T extends Element = HTMLElement, TScope = object>(nodes: NodeList, callback: (this: TScope, $element: T, index: number) => any, scope?: TScope): void;
9
+ export default forEach;
package/forEach.js ADDED
@@ -0,0 +1,13 @@
1
+ /**
2
+ * For each, iterate through a NodeList of HTMLElements
3
+ *
4
+ * @param nodes DOM nodes collection
5
+ * @param callback
6
+ * @param scope
7
+ */
8
+ export function forEach(nodes, callback, scope) {
9
+ for (var i = 0; i < nodes.length; i++) {
10
+ callback.call(scope, nodes[i], i);
11
+ }
12
+ }
13
+ export default forEach;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Get data attribute
3
+ *
4
+ * @param element
5
+ * @param attribute The name of the `data-{attr}`
6
+ */
7
+ export declare function getDataAttr(element: HTMLElement, attribute: string): string | null;
8
+ export default getDataAttr;
package/getDataAttr.js ADDED
@@ -0,0 +1,13 @@
1
+ // TODO: maybe move to `dataset` API but consider the comment about Safari here
2
+ // https://stackoverflow.com/a/9201264/1938970
3
+ /**
4
+ * Get data attribute
5
+ *
6
+ * @param element
7
+ * @param attribute The name of the `data-{attr}`
8
+ */
9
+ export function getDataAttr(element, attribute) {
10
+ // return element.dataset[attribute];
11
+ return element.getAttribute("data-" + attribute);
12
+ }
13
+ export default getDataAttr;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Determine the document's height
3
+ *
4
+ * @see https://github.com/cferdinandi/smooth-scroll (credits)
5
+ */
6
+ export declare function getDocumentHeight(): number;
7
+ export default getDocumentHeight;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Determine the document's height
3
+ *
4
+ * @see https://github.com/cferdinandi/smooth-scroll (credits)
5
+ */
6
+ export function getDocumentHeight() {
7
+ var body = document.body, documentElement = document.documentElement;
8
+ return Math.max(body.scrollHeight, documentElement.scrollHeight, body.offsetHeight, documentElement.offsetHeight, body.clientHeight, documentElement.clientHeight);
9
+ }
10
+ export default getDocumentHeight;
package/getHeight.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Get element height
3
+ */
4
+ export declare function getHeight(element: HTMLElement): number;
5
+ export default getHeight;
package/getHeight.js ADDED
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Get element height
3
+ */
4
+ export function getHeight(element) {
5
+ return parseInt(window.getComputedStyle(element).height, 10);
6
+ }
7
+ export default getHeight;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Get an immutable copy of all active event listeners
3
+ *
4
+ * @category listen-delegation
5
+ *
6
+ * @return Active event listeners
7
+ */
8
+ export declare function getListeners(): Record<string, import("./_listen-delegation").ListenEvent[]>;
9
+ export default getListeners;
@@ -0,0 +1,18 @@
1
+ import { activeEvents } from "./_listen-delegation";
2
+ /**
3
+ * Get an immutable copy of all active event listeners
4
+ *
5
+ * @category listen-delegation
6
+ *
7
+ * @return Active event listeners
8
+ */
9
+ export function getListeners() {
10
+ var obj = {};
11
+ for (var type in activeEvents) {
12
+ // if (activeEvents.hasOwnProperty(type)) {
13
+ obj[type] = activeEvents[type];
14
+ // }
15
+ }
16
+ return obj;
17
+ }
18
+ export default getListeners;
package/getOffset.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Get an element's distance from the top and left of the Document.
3
+ *
4
+ * @param elem The HTML node element
5
+ * @return Distance from the top and left in pixels
6
+ */
7
+ export declare function getOffset(elem: HTMLElement): {
8
+ top: number;
9
+ left: number;
10
+ };
11
+ export default getOffset;
package/getOffset.js ADDED
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Get an element's distance from the top and left of the Document.
3
+ *
4
+ * @param elem The HTML node element
5
+ * @return Distance from the top and left in pixels
6
+ */
7
+ export function getOffset(elem) {
8
+ var left = 0;
9
+ var top = 0;
10
+ while (elem && !isNaN(elem.offsetLeft) && !isNaN(elem.offsetTop)) {
11
+ left += elem.offsetLeft - elem.scrollLeft;
12
+ top += elem.offsetTop - elem.scrollTop;
13
+ // @ts-expect-error nevermind?
14
+ elem = elem.offsetParent;
15
+ }
16
+ return { top: top, left: left };
17
+ }
18
+ export default getOffset;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Get an element's distance from the top of the Document.
3
+ *
4
+ * @see https://vanillajstoolkit.com/helpers/getoffsettop/
5
+ *
6
+ * @param elem The HTML node element
7
+ * @return Distance from the top in pixels
8
+ */
9
+ export declare function getOffsetTop(elem: HTMLElement): number;
10
+ export default getOffsetTop;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Get an element's distance from the top of the Document.
3
+ *
4
+ * @see https://vanillajstoolkit.com/helpers/getoffsettop/
5
+ *
6
+ * @param elem The HTML node element
7
+ * @return Distance from the top in pixels
8
+ */
9
+ export function getOffsetTop(elem) {
10
+ var location = 0;
11
+ if (elem.offsetParent) {
12
+ while (elem) {
13
+ location += elem.offsetTop;
14
+ // @ts-expect-error nevermind?
15
+ elem = elem.offsetParent;
16
+ }
17
+ }
18
+ return location >= 0 ? location : 0;
19
+ }
20
+ export default getOffsetTop;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Get scrollbar's current width
3
+ */
4
+ export declare function getScrollbarWidth(element?: HTMLElement): number;
5
+ export default getScrollbarWidth;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Get scrollbar's current width
3
+ */
4
+ export function getScrollbarWidth(element) {
5
+ return window.innerWidth - (element || document.documentElement).clientWidth;
6
+ }
7
+ export default getScrollbarWidth;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Return the current style value for an element CSS property
3
+ *
4
+ * @param el The element to compute
5
+ * @param prop The style property
6
+ */
7
+ export declare function getStyleValue(el: HTMLElement, prop: string): string;
8
+ export default getStyleValue;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Return the current style value for an element CSS property
3
+ *
4
+ * @param el The element to compute
5
+ * @param prop The style property
6
+ */
7
+ export function getStyleValue(el, prop) {
8
+ return getComputedStyle(el, null).getPropertyValue(prop);
9
+ }
10
+ export default getStyleValue;
package/index.d.ts ADDED
@@ -0,0 +1,40 @@
1
+ export * from "./$$";
2
+ export * from "./$each";
3
+ export * from "./$";
4
+ export * from "./addClass";
5
+ export * from "./calculateFixedOffset";
6
+ export * from "./createElement";
7
+ export * from "./emitEvent";
8
+ export * from "./escapeSelector";
9
+ export * from "./exists";
10
+ export * from "./forEach";
11
+ export * from "./getDataAttr";
12
+ export * from "./getDocumentHeight";
13
+ export * from "./getHeight";
14
+ export * from "./getListeners";
15
+ export * from "./getOffsetTop";
16
+ export * from "./getOffset";
17
+ export * from "./getScrollbarWidth";
18
+ export * from "./getStyleValue";
19
+ export * from "./index";
20
+ export * from "./injectCss";
21
+ export * from "./isHidden";
22
+ export * from "./isInViewport";
23
+ export * from "./isNodeList";
24
+ export * from "./isTotallyScrolled";
25
+ export * from "./listenLoaded";
26
+ export * from "./listenOnce";
27
+ export * from "./listenResize";
28
+ export * from "./listenScroll";
29
+ export * from "./listen";
30
+ export * from "./off";
31
+ export * from "./once";
32
+ export * from "./onClickOutside";
33
+ export * from "./on";
34
+ export * from "./removeClass";
35
+ export * from "./scrollTo";
36
+ export * from "./setDataAttr";
37
+ export * from "./setVendorCSS";
38
+ export * from "./siblings";
39
+ export * from "./toArray";
40
+ export * from "./unlisten";
package/index.js ADDED
@@ -0,0 +1,40 @@
1
+ export * from "./$$";
2
+ export * from "./$each";
3
+ export * from "./$";
4
+ export * from "./addClass";
5
+ export * from "./calculateFixedOffset";
6
+ export * from "./createElement";
7
+ export * from "./emitEvent";
8
+ export * from "./escapeSelector";
9
+ export * from "./exists";
10
+ export * from "./forEach";
11
+ export * from "./getDataAttr";
12
+ export * from "./getDocumentHeight";
13
+ export * from "./getHeight";
14
+ export * from "./getListeners";
15
+ export * from "./getOffsetTop";
16
+ export * from "./getOffset";
17
+ export * from "./getScrollbarWidth";
18
+ export * from "./getStyleValue";
19
+ export * from "./index";
20
+ export * from "./injectCss";
21
+ export * from "./isHidden";
22
+ export * from "./isInViewport";
23
+ export * from "./isNodeList";
24
+ export * from "./isTotallyScrolled";
25
+ export * from "./listenLoaded";
26
+ export * from "./listenOnce";
27
+ export * from "./listenResize";
28
+ export * from "./listenScroll";
29
+ export * from "./listen";
30
+ export * from "./off";
31
+ export * from "./once";
32
+ export * from "./onClickOutside";
33
+ export * from "./on";
34
+ export * from "./removeClass";
35
+ export * from "./scrollTo";
36
+ export * from "./setDataAttr";
37
+ export * from "./setVendorCSS";
38
+ export * from "./siblings";
39
+ export * from "./toArray";
40
+ export * from "./unlisten";
package/injectCss.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Inject css
3
+ */
4
+ export declare function injectCss(id: string, cssString?: string, root?: Document): void;
5
+ export default injectCss;