@koine/dom 1.1.10 → 1.1.11
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/$$.js +6 -2
- package/{node/$$.js → $$.mjs} +2 -6
- package/$.js +6 -2
- package/{node/$.js → $.mjs} +2 -6
- package/$each.js +9 -4
- package/{node/$each.js → $each.mjs} +4 -9
- package/_listen-delegation.js +17 -10
- package/{node/_listen-delegation.js → _listen-delegation.mjs} +10 -17
- package/addClass.js +6 -2
- package/{node/addClass.js → addClass.mjs} +2 -6
- package/calculateFixedOffset.js +8 -4
- package/calculateFixedOffset.mjs +10 -0
- package/createElement.js +9 -4
- package/createElement.mjs +16 -0
- package/emitEvent.js +6 -2
- package/{node/emitEvent.js → emitEvent.mjs} +2 -6
- package/escapeSelector.js +6 -2
- package/{node/escapeSelector.js → escapeSelector.mjs} +2 -6
- package/exists.js +6 -2
- package/{node/exists.js → exists.mjs} +2 -6
- package/forEach.js +6 -2
- package/{node/forEach.js → forEach.mjs} +2 -6
- package/getDataAttr.js +6 -2
- package/{node/getDataAttr.js → getDataAttr.mjs} +2 -6
- package/getDocumentHeight.js +6 -2
- package/{node/getDocumentHeight.js → getDocumentHeight.mjs} +2 -6
- package/getHeight.js +6 -2
- package/getHeight.mjs +7 -0
- package/getListeners.js +9 -5
- package/getListeners.mjs +18 -0
- package/getOffset.js +6 -2
- package/{node/getOffset.js → getOffset.mjs} +2 -6
- package/getOffsetTop.js +6 -2
- package/{node/getOffsetTop.js → getOffsetTop.mjs} +2 -6
- package/getOffsetTopSlim.js +6 -2
- package/{node/getOffsetTopSlim.js → getOffsetTopSlim.mjs} +2 -6
- package/getScrollbarWidth.js +6 -2
- package/getScrollbarWidth.mjs +7 -0
- package/getStyleValue.js +6 -2
- package/getStyleValue.mjs +10 -0
- package/index.js +48 -45
- package/index.mjs +45 -0
- package/injectCss.js +6 -2
- package/{node/injectCss.js → injectCss.mjs} +2 -6
- package/isHidden.js +6 -2
- package/isHidden.mjs +7 -0
- package/isInViewport.js +6 -2
- package/{node/isInViewport.js → isInViewport.mjs} +2 -6
- package/isNodeList.js +6 -2
- package/{node/isNodeList.js → isNodeList.mjs} +2 -6
- package/isTotallyScrolled.js +6 -2
- package/{node/isTotallyScrolled.js → isTotallyScrolled.mjs} +2 -6
- package/listen.js +12 -8
- package/{node/listen.js → listen.mjs} +8 -12
- package/listenLoaded.js +8 -4
- package/listenLoaded.mjs +11 -0
- package/listenOnce.js +12 -8
- package/listenOnce.mjs +20 -0
- package/listenResize.js +7 -3
- package/listenResize.mjs +8 -0
- package/listenResizeDebounced.js +10 -5
- package/{node/listenResizeDebounced.js → listenResizeDebounced.mjs} +5 -10
- package/listenResizeThrottled.js +10 -5
- package/listenResizeThrottled.mjs +15 -0
- package/listenScroll.js +8 -4
- package/listenScroll.mjs +13 -0
- package/listenScrollDebounced.js +10 -5
- package/listenScrollDebounced.mjs +15 -0
- package/listenScrollThrottled.js +10 -5
- package/listenScrollThrottled.mjs +15 -0
- package/off.js +6 -2
- package/{node/off.js → off.mjs} +2 -6
- package/on.js +9 -4
- package/{node/on.js → on.mjs} +4 -9
- package/onClickOutside.js +8 -4
- package/{node/onClickOutside.js → onClickOutside.mjs} +4 -8
- package/once.js +11 -6
- package/once.mjs +15 -0
- package/package.json +3 -3
- package/removeClass.js +6 -2
- package/{node/removeClass.js → removeClass.mjs} +2 -6
- package/scrollTo.js +11 -7
- package/{node/scrollTo.js → scrollTo.mjs} +7 -11
- package/setDataAttr.js +6 -2
- package/{node/setDataAttr.js → setDataAttr.mjs} +2 -6
- package/setVendorCSS.js +6 -2
- package/{node/setVendorCSS.js → setVendorCSS.mjs} +2 -6
- package/siblings.js +6 -2
- package/{node/siblings.js → siblings.mjs} +2 -6
- package/toArray.js +6 -2
- package/toArray.mjs +9 -0
- package/types.js +2 -1
- package/types.mjs +1 -0
- package/unlisten.js +14 -10
- package/unlisten.mjs +33 -0
- package/node/calculateFixedOffset.js +0 -14
- package/node/createElement.js +0 -21
- package/node/getHeight.js +0 -11
- package/node/getListeners.js +0 -22
- package/node/getScrollbarWidth.js +0 -11
- package/node/getStyleValue.js +0 -14
- package/node/index.js +0 -48
- package/node/isHidden.js +0 -11
- package/node/listenLoaded.js +0 -15
- package/node/listenOnce.js +0 -24
- package/node/listenResize.js +0 -12
- package/node/listenResizeThrottled.js +0 -20
- package/node/listenScroll.js +0 -17
- package/node/listenScrollDebounced.js +0 -20
- package/node/listenScrollThrottled.js +0 -20
- package/node/once.js +0 -20
- package/node/toArray.js +0 -13
- package/node/types.js +0 -2
- package/node/unlisten.js +0 -37
package/$$.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.$$ = void 0;
|
|
1
4
|
/**
|
|
2
5
|
* Sizzle/jQuery like DOM nodes shortcut for `document.querySelectorAll`
|
|
3
6
|
* To avoid an extra function call we inline the above `escape`
|
|
@@ -6,7 +9,8 @@
|
|
|
6
9
|
* @param parent It falls back to `window.document`
|
|
7
10
|
* @param avoidEscape Whether to avoid escaping `:` in the selector string
|
|
8
11
|
*/
|
|
9
|
-
|
|
12
|
+
function $$(selector, parent, avoidEscape) {
|
|
10
13
|
return (parent ? parent : document).querySelectorAll(avoidEscape ? selector : selector.replace(/:/g, "\\:"));
|
|
11
14
|
}
|
|
12
|
-
|
|
15
|
+
exports.$$ = $$;
|
|
16
|
+
exports.default = $$;
|
package/{node/$$.js → $$.mjs}
RENAMED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.$$ = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Sizzle/jQuery like DOM nodes shortcut for `document.querySelectorAll`
|
|
6
3
|
* To avoid an extra function call we inline the above `escape`
|
|
@@ -9,8 +6,7 @@ exports.$$ = void 0;
|
|
|
9
6
|
* @param parent It falls back to `window.document`
|
|
10
7
|
* @param avoidEscape Whether to avoid escaping `:` in the selector string
|
|
11
8
|
*/
|
|
12
|
-
function $$(selector, parent, avoidEscape) {
|
|
9
|
+
export function $$(selector, parent, avoidEscape) {
|
|
13
10
|
return (parent ? parent : document).querySelectorAll(avoidEscape ? selector : selector.replace(/:/g, "\\:"));
|
|
14
11
|
}
|
|
15
|
-
|
|
16
|
-
exports.default = $$;
|
|
12
|
+
export default $$;
|
package/$.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.$ = void 0;
|
|
1
4
|
/**
|
|
2
5
|
* Sizzle/jQuery like DOM nodes shortcut for `document.querySelector`
|
|
3
6
|
* To avoid an extra function call we inline the above `escape`
|
|
@@ -9,7 +12,8 @@
|
|
|
9
12
|
* const $container = $(".my-section:");
|
|
10
13
|
* const $el = $("[data-some-attr]", $container);
|
|
11
14
|
*/
|
|
12
|
-
|
|
15
|
+
function $(selector, parent, avoidEscape) {
|
|
13
16
|
return (parent ? parent : document).querySelector(avoidEscape ? selector : selector.replace(/:/g, "\\:"));
|
|
14
17
|
}
|
|
15
|
-
|
|
18
|
+
exports.$ = $;
|
|
19
|
+
exports.default = $;
|
package/{node/$.js → $.mjs}
RENAMED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.$ = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Sizzle/jQuery like DOM nodes shortcut for `document.querySelector`
|
|
6
3
|
* To avoid an extra function call we inline the above `escape`
|
|
@@ -12,8 +9,7 @@ exports.$ = void 0;
|
|
|
12
9
|
* const $container = $(".my-section:");
|
|
13
10
|
* const $el = $("[data-some-attr]", $container);
|
|
14
11
|
*/
|
|
15
|
-
function $(selector, parent, avoidEscape) {
|
|
12
|
+
export function $(selector, parent, avoidEscape) {
|
|
16
13
|
return (parent ? parent : document).querySelector(avoidEscape ? selector : selector.replace(/:/g, "\\:"));
|
|
17
14
|
}
|
|
18
|
-
|
|
19
|
-
exports.default = $;
|
|
15
|
+
export default $;
|
package/$each.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.$each = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var __1 = tslib_1.__importDefault(require("./$$"));
|
|
2
6
|
/**
|
|
3
7
|
* Each shortcut, iterate through a NodeList of HTMLElements retrieved with the
|
|
4
8
|
* given selector (and optionally a parent container passed as thrid arguement)
|
|
@@ -8,10 +12,11 @@ import $$ from "./$$";
|
|
|
8
12
|
* @param parent It falls back to `window.document`
|
|
9
13
|
* @param scope
|
|
10
14
|
*/
|
|
11
|
-
|
|
12
|
-
var nodes =
|
|
15
|
+
function $each(selector, callback, parent, scope) {
|
|
16
|
+
var nodes = (0, __1.default)(selector, parent);
|
|
13
17
|
for (var i = 0; i < nodes.length; i++) {
|
|
14
18
|
callback.call(scope, nodes[i], i);
|
|
15
19
|
}
|
|
16
20
|
}
|
|
17
|
-
|
|
21
|
+
exports.$each = $each;
|
|
22
|
+
exports.default = $each;
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.$each = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var __1 = tslib_1.__importDefault(require("./$$"));
|
|
1
|
+
import $$ from "./$$";
|
|
6
2
|
/**
|
|
7
3
|
* Each shortcut, iterate through a NodeList of HTMLElements retrieved with the
|
|
8
4
|
* given selector (and optionally a parent container passed as thrid arguement)
|
|
@@ -12,11 +8,10 @@ var __1 = tslib_1.__importDefault(require("./$$"));
|
|
|
12
8
|
* @param parent It falls back to `window.document`
|
|
13
9
|
* @param scope
|
|
14
10
|
*/
|
|
15
|
-
function $each(selector, callback, parent, scope) {
|
|
16
|
-
var nodes = (
|
|
11
|
+
export function $each(selector, callback, parent, scope) {
|
|
12
|
+
var nodes = $$(selector, parent);
|
|
17
13
|
for (var i = 0; i < nodes.length; i++) {
|
|
18
14
|
callback.call(scope, nodes[i], i);
|
|
19
15
|
}
|
|
20
16
|
}
|
|
21
|
-
|
|
22
|
-
exports.default = $each;
|
|
17
|
+
export default $each;
|
package/_listen-delegation.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.eventHandler = exports.getRunTarget = exports.getIndex = exports.activeEvents = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
1
5
|
/**
|
|
2
6
|
* Listen: events delegation system
|
|
3
7
|
*
|
|
@@ -7,20 +11,20 @@
|
|
|
7
11
|
*
|
|
8
12
|
* @fileoverview
|
|
9
13
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
14
|
+
var isString_1 = tslib_1.__importDefault(require("@koine/utils/isString"));
|
|
15
|
+
var escapeSelector_1 = tslib_1.__importDefault(require("./escapeSelector"));
|
|
12
16
|
/**
|
|
13
17
|
* Active events
|
|
14
18
|
*
|
|
15
19
|
* @internal
|
|
16
20
|
*/
|
|
17
|
-
|
|
21
|
+
exports.activeEvents = {};
|
|
18
22
|
/**
|
|
19
23
|
* Get the index for the listener
|
|
20
24
|
*
|
|
21
25
|
* @internal
|
|
22
26
|
*/
|
|
23
|
-
|
|
27
|
+
function getIndex(arr, selector, callback) {
|
|
24
28
|
for (var i = 0; i < arr.length; i++) {
|
|
25
29
|
if (arr[i].selector === selector &&
|
|
26
30
|
arr[i].callback.toString() === callback.toString())
|
|
@@ -28,6 +32,7 @@ export function getIndex(arr, selector, callback) {
|
|
|
28
32
|
}
|
|
29
33
|
return -1;
|
|
30
34
|
}
|
|
35
|
+
exports.getIndex = getIndex;
|
|
31
36
|
/**
|
|
32
37
|
* Check if the listener callback should run or not
|
|
33
38
|
*
|
|
@@ -36,7 +41,7 @@ export function getIndex(arr, selector, callback) {
|
|
|
36
41
|
* @param selector The selector/element to check the target against
|
|
37
42
|
* @return If not false, run listener and pass the targeted element to use in the callback
|
|
38
43
|
*/
|
|
39
|
-
|
|
44
|
+
function getRunTarget(target, selector) {
|
|
40
45
|
// @ts-expect-error FIXME: type
|
|
41
46
|
if (["*", "window", window].includes(selector)) {
|
|
42
47
|
return window;
|
|
@@ -49,8 +54,8 @@ export function getRunTarget(target, selector) {
|
|
|
49
54
|
// @ts-expect-error FIXME: type
|
|
50
55
|
].includes(selector))
|
|
51
56
|
return document;
|
|
52
|
-
if (
|
|
53
|
-
return target.closest(
|
|
57
|
+
if ((0, isString_1.default)(selector)) {
|
|
58
|
+
return target.closest((0, escapeSelector_1.default)(selector));
|
|
54
59
|
}
|
|
55
60
|
// @ts-expect-error FIXME: type
|
|
56
61
|
if (typeof selector !== "string" && selector.contains) {
|
|
@@ -65,15 +70,16 @@ export function getRunTarget(target, selector) {
|
|
|
65
70
|
}
|
|
66
71
|
return false;
|
|
67
72
|
}
|
|
73
|
+
exports.getRunTarget = getRunTarget;
|
|
68
74
|
/**
|
|
69
75
|
* Handle listeners after event fires
|
|
70
76
|
*
|
|
71
77
|
* @internal
|
|
72
78
|
*/
|
|
73
|
-
|
|
74
|
-
if (!activeEvents[event.type])
|
|
79
|
+
function eventHandler(event) {
|
|
80
|
+
if (!exports.activeEvents[event.type])
|
|
75
81
|
return;
|
|
76
|
-
activeEvents[event.type].forEach(function (listener) {
|
|
82
|
+
exports.activeEvents[event.type].forEach(function (listener) {
|
|
77
83
|
var target = getRunTarget(event.target, listener.selector);
|
|
78
84
|
if (!target) {
|
|
79
85
|
return;
|
|
@@ -81,3 +87,4 @@ export function eventHandler(event) {
|
|
|
81
87
|
listener.callback(event, target);
|
|
82
88
|
});
|
|
83
89
|
}
|
|
90
|
+
exports.eventHandler = eventHandler;
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.eventHandler = exports.getRunTarget = exports.getIndex = exports.activeEvents = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
1
|
/**
|
|
6
2
|
* Listen: events delegation system
|
|
7
3
|
*
|
|
@@ -11,20 +7,20 @@ var tslib_1 = require("tslib");
|
|
|
11
7
|
*
|
|
12
8
|
* @fileoverview
|
|
13
9
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
import isString from "@koine/utils/isString";
|
|
11
|
+
import escapeSelector from "./escapeSelector";
|
|
16
12
|
/**
|
|
17
13
|
* Active events
|
|
18
14
|
*
|
|
19
15
|
* @internal
|
|
20
16
|
*/
|
|
21
|
-
|
|
17
|
+
export var activeEvents = {};
|
|
22
18
|
/**
|
|
23
19
|
* Get the index for the listener
|
|
24
20
|
*
|
|
25
21
|
* @internal
|
|
26
22
|
*/
|
|
27
|
-
function getIndex(arr, selector, callback) {
|
|
23
|
+
export function getIndex(arr, selector, callback) {
|
|
28
24
|
for (var i = 0; i < arr.length; i++) {
|
|
29
25
|
if (arr[i].selector === selector &&
|
|
30
26
|
arr[i].callback.toString() === callback.toString())
|
|
@@ -32,7 +28,6 @@ function getIndex(arr, selector, callback) {
|
|
|
32
28
|
}
|
|
33
29
|
return -1;
|
|
34
30
|
}
|
|
35
|
-
exports.getIndex = getIndex;
|
|
36
31
|
/**
|
|
37
32
|
* Check if the listener callback should run or not
|
|
38
33
|
*
|
|
@@ -41,7 +36,7 @@ exports.getIndex = getIndex;
|
|
|
41
36
|
* @param selector The selector/element to check the target against
|
|
42
37
|
* @return If not false, run listener and pass the targeted element to use in the callback
|
|
43
38
|
*/
|
|
44
|
-
function getRunTarget(target, selector) {
|
|
39
|
+
export function getRunTarget(target, selector) {
|
|
45
40
|
// @ts-expect-error FIXME: type
|
|
46
41
|
if (["*", "window", window].includes(selector)) {
|
|
47
42
|
return window;
|
|
@@ -54,8 +49,8 @@ function getRunTarget(target, selector) {
|
|
|
54
49
|
// @ts-expect-error FIXME: type
|
|
55
50
|
].includes(selector))
|
|
56
51
|
return document;
|
|
57
|
-
if ((
|
|
58
|
-
return target.closest((
|
|
52
|
+
if (isString(selector)) {
|
|
53
|
+
return target.closest(escapeSelector(selector));
|
|
59
54
|
}
|
|
60
55
|
// @ts-expect-error FIXME: type
|
|
61
56
|
if (typeof selector !== "string" && selector.contains) {
|
|
@@ -70,16 +65,15 @@ function getRunTarget(target, selector) {
|
|
|
70
65
|
}
|
|
71
66
|
return false;
|
|
72
67
|
}
|
|
73
|
-
exports.getRunTarget = getRunTarget;
|
|
74
68
|
/**
|
|
75
69
|
* Handle listeners after event fires
|
|
76
70
|
*
|
|
77
71
|
* @internal
|
|
78
72
|
*/
|
|
79
|
-
function eventHandler(event) {
|
|
80
|
-
if (!
|
|
73
|
+
export function eventHandler(event) {
|
|
74
|
+
if (!activeEvents[event.type])
|
|
81
75
|
return;
|
|
82
|
-
|
|
76
|
+
activeEvents[event.type].forEach(function (listener) {
|
|
83
77
|
var target = getRunTarget(event.target, listener.selector);
|
|
84
78
|
if (!target) {
|
|
85
79
|
return;
|
|
@@ -87,4 +81,3 @@ function eventHandler(event) {
|
|
|
87
81
|
listener.callback(event, target);
|
|
88
82
|
});
|
|
89
83
|
}
|
|
90
|
-
exports.eventHandler = eventHandler;
|
package/addClass.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addClass = void 0;
|
|
1
4
|
/**
|
|
2
5
|
* Add class shortcut
|
|
3
6
|
*/
|
|
4
|
-
|
|
7
|
+
function addClass(el, className) {
|
|
5
8
|
if (className === void 0) { className = ""; }
|
|
6
9
|
if (process.env["NODE_ENV"] !== "production") {
|
|
7
10
|
if (!el) {
|
|
@@ -12,4 +15,5 @@ export function addClass(el, className) {
|
|
|
12
15
|
if (el)
|
|
13
16
|
el.classList.add(className);
|
|
14
17
|
}
|
|
15
|
-
|
|
18
|
+
exports.addClass = addClass;
|
|
19
|
+
exports.default = addClass;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addClass = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Add class shortcut
|
|
6
3
|
*/
|
|
7
|
-
function addClass(el, className) {
|
|
4
|
+
export function addClass(el, className) {
|
|
8
5
|
if (className === void 0) { className = ""; }
|
|
9
6
|
if (process.env["NODE_ENV"] !== "production") {
|
|
10
7
|
if (!el) {
|
|
@@ -15,5 +12,4 @@ function addClass(el, className) {
|
|
|
15
12
|
if (el)
|
|
16
13
|
el.classList.add(className);
|
|
17
14
|
}
|
|
18
|
-
|
|
19
|
-
exports.default = addClass;
|
|
15
|
+
export default addClass;
|
package/calculateFixedOffset.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.calculateFixedOffset = void 0;
|
|
4
|
+
var _each_1 = require("./$each");
|
|
5
|
+
function calculateFixedOffset(selector) {
|
|
3
6
|
if (selector === void 0) { selector = "[data-fixed]"; }
|
|
4
7
|
var fixedOffset = 0;
|
|
5
|
-
|
|
8
|
+
(0, _each_1.$each)(selector, function ($el) {
|
|
6
9
|
fixedOffset += $el.offsetHeight;
|
|
7
10
|
});
|
|
8
11
|
return fixedOffset;
|
|
9
12
|
}
|
|
10
|
-
|
|
13
|
+
exports.calculateFixedOffset = calculateFixedOffset;
|
|
14
|
+
exports.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;
|
package/createElement.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createElement = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var addClass_1 = tslib_1.__importDefault(require("./addClass"));
|
|
2
6
|
/**
|
|
3
7
|
* Shortcut for `document.createElement`, allowing to to create an HTML element
|
|
4
8
|
* with a given className directly (a very common use case)
|
|
@@ -6,11 +10,12 @@ import addClass from "./addClass";
|
|
|
6
10
|
* @param type
|
|
7
11
|
* @param className
|
|
8
12
|
*/
|
|
9
|
-
|
|
13
|
+
function createElement(type, className) {
|
|
10
14
|
var el = document.createElement(type);
|
|
11
15
|
if (className) {
|
|
12
|
-
|
|
16
|
+
(0, addClass_1.default)(el, className);
|
|
13
17
|
}
|
|
14
18
|
return el;
|
|
15
19
|
}
|
|
16
|
-
|
|
20
|
+
exports.createElement = createElement;
|
|
21
|
+
exports.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.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.emitEvent = void 0;
|
|
1
4
|
/**
|
|
2
5
|
* Emit event (use only if the targeted browser supports `CustomEvent`s)
|
|
3
6
|
*/
|
|
4
|
-
|
|
7
|
+
function emitEvent(type, detail) {
|
|
5
8
|
if (type === void 0) { type = "customEvent"; }
|
|
6
9
|
if (detail === void 0) { detail = {}; }
|
|
7
10
|
if (typeof window.CustomEvent !== "function")
|
|
@@ -11,4 +14,5 @@ export function emitEvent(type, detail) {
|
|
|
11
14
|
detail: detail,
|
|
12
15
|
}));
|
|
13
16
|
}
|
|
14
|
-
|
|
17
|
+
exports.emitEvent = emitEvent;
|
|
18
|
+
exports.default = emitEvent;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.emitEvent = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Emit event (use only if the targeted browser supports `CustomEvent`s)
|
|
6
3
|
*/
|
|
7
|
-
function emitEvent(type, detail) {
|
|
4
|
+
export function emitEvent(type, detail) {
|
|
8
5
|
if (type === void 0) { type = "customEvent"; }
|
|
9
6
|
if (detail === void 0) { detail = {}; }
|
|
10
7
|
if (typeof window.CustomEvent !== "function")
|
|
@@ -14,5 +11,4 @@ function emitEvent(type, detail) {
|
|
|
14
11
|
detail: detail,
|
|
15
12
|
}));
|
|
16
13
|
}
|
|
17
|
-
|
|
18
|
-
exports.default = emitEvent;
|
|
14
|
+
export default emitEvent;
|
package/escapeSelector.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.escapeSelector = void 0;
|
|
1
4
|
/**
|
|
2
5
|
* Escape colons to allow use class names as `.module:block__element`
|
|
3
6
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector#Escaping_special_characters
|
|
4
7
|
*
|
|
5
8
|
* @param selector
|
|
6
9
|
*/
|
|
7
|
-
|
|
10
|
+
function escapeSelector(selector) {
|
|
8
11
|
return selector.replace(/:/g, "\\:");
|
|
9
12
|
}
|
|
10
|
-
|
|
13
|
+
exports.escapeSelector = escapeSelector;
|
|
14
|
+
exports.default = escapeSelector;
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.escapeSelector = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Escape colons to allow use class names as `.module:block__element`
|
|
6
3
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector#Escaping_special_characters
|
|
7
4
|
*
|
|
8
5
|
* @param selector
|
|
9
6
|
*/
|
|
10
|
-
function escapeSelector(selector) {
|
|
7
|
+
export function escapeSelector(selector) {
|
|
11
8
|
return selector.replace(/:/g, "\\:");
|
|
12
9
|
}
|
|
13
|
-
|
|
14
|
-
exports.default = escapeSelector;
|
|
10
|
+
export default escapeSelector;
|
package/exists.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.exists = void 0;
|
|
1
4
|
/**
|
|
2
5
|
* Checks if passed node exist and is a valid element.
|
|
3
6
|
*
|
|
4
7
|
* @borrows @glidejs/glide/src/utils/dom (source)
|
|
5
8
|
*/
|
|
6
|
-
|
|
9
|
+
function exists(node) {
|
|
7
10
|
if (node && node instanceof window.HTMLElement) {
|
|
8
11
|
return true;
|
|
9
12
|
}
|
|
10
13
|
return false;
|
|
11
14
|
}
|
|
12
|
-
|
|
15
|
+
exports.exists = exists;
|
|
16
|
+
exports.default = exists;
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.exists = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Checks if passed node exist and is a valid element.
|
|
6
3
|
*
|
|
7
4
|
* @borrows @glidejs/glide/src/utils/dom (source)
|
|
8
5
|
*/
|
|
9
|
-
function exists(node) {
|
|
6
|
+
export function exists(node) {
|
|
10
7
|
if (node && node instanceof window.HTMLElement) {
|
|
11
8
|
return true;
|
|
12
9
|
}
|
|
13
10
|
return false;
|
|
14
11
|
}
|
|
15
|
-
|
|
16
|
-
exports.default = exists;
|
|
12
|
+
export default exists;
|
package/forEach.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.forEach = void 0;
|
|
1
4
|
/**
|
|
2
5
|
* For each, iterate through a NodeList of HTMLElements
|
|
3
6
|
*
|
|
@@ -5,9 +8,10 @@
|
|
|
5
8
|
* @param callback
|
|
6
9
|
* @param scope
|
|
7
10
|
*/
|
|
8
|
-
|
|
11
|
+
function forEach(nodes, callback, scope) {
|
|
9
12
|
for (var i = 0; i < nodes.length; i++) {
|
|
10
13
|
callback.call(scope, nodes[i], i);
|
|
11
14
|
}
|
|
12
15
|
}
|
|
13
|
-
|
|
16
|
+
exports.forEach = forEach;
|
|
17
|
+
exports.default = forEach;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.forEach = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* For each, iterate through a NodeList of HTMLElements
|
|
6
3
|
*
|
|
@@ -8,10 +5,9 @@ exports.forEach = void 0;
|
|
|
8
5
|
* @param callback
|
|
9
6
|
* @param scope
|
|
10
7
|
*/
|
|
11
|
-
function forEach(nodes, callback, scope) {
|
|
8
|
+
export function forEach(nodes, callback, scope) {
|
|
12
9
|
for (var i = 0; i < nodes.length; i++) {
|
|
13
10
|
callback.call(scope, nodes[i], i);
|
|
14
11
|
}
|
|
15
12
|
}
|
|
16
|
-
|
|
17
|
-
exports.default = forEach;
|
|
13
|
+
export default forEach;
|
package/getDataAttr.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
// TODO: maybe move to `dataset` API but consider the comment about Safari here
|
|
2
3
|
// https://stackoverflow.com/a/9201264/1938970
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.getDataAttr = void 0;
|
|
3
6
|
/**
|
|
4
7
|
* Get data attribute
|
|
5
8
|
*
|
|
6
9
|
* @param element
|
|
7
10
|
* @param attribute The name of the `data-{attr}`
|
|
8
11
|
*/
|
|
9
|
-
|
|
12
|
+
function getDataAttr(element, attribute) {
|
|
10
13
|
// return element.dataset[attribute];
|
|
11
14
|
return element.getAttribute("data-" + attribute);
|
|
12
15
|
}
|
|
13
|
-
|
|
16
|
+
exports.getDataAttr = getDataAttr;
|
|
17
|
+
exports.default = getDataAttr;
|
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// TODO: maybe move to `dataset` API but consider the comment about Safari here
|
|
3
2
|
// https://stackoverflow.com/a/9201264/1938970
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.getDataAttr = void 0;
|
|
6
3
|
/**
|
|
7
4
|
* Get data attribute
|
|
8
5
|
*
|
|
9
6
|
* @param element
|
|
10
7
|
* @param attribute The name of the `data-{attr}`
|
|
11
8
|
*/
|
|
12
|
-
function getDataAttr(element, attribute) {
|
|
9
|
+
export function getDataAttr(element, attribute) {
|
|
13
10
|
// return element.dataset[attribute];
|
|
14
11
|
return element.getAttribute("data-" + attribute);
|
|
15
12
|
}
|
|
16
|
-
|
|
17
|
-
exports.default = getDataAttr;
|
|
13
|
+
export default getDataAttr;
|
package/getDocumentHeight.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDocumentHeight = void 0;
|
|
1
4
|
/**
|
|
2
5
|
* Determine the document's height
|
|
3
6
|
*
|
|
4
7
|
* @see https://github.com/cferdinandi/smooth-scroll (credits)
|
|
5
8
|
*/
|
|
6
|
-
|
|
9
|
+
function getDocumentHeight() {
|
|
7
10
|
var body = document.body, documentElement = document.documentElement;
|
|
8
11
|
return Math.max(body.scrollHeight, documentElement.scrollHeight, body.offsetHeight, documentElement.offsetHeight, body.clientHeight, documentElement.clientHeight);
|
|
9
12
|
}
|
|
10
|
-
|
|
13
|
+
exports.getDocumentHeight = getDocumentHeight;
|
|
14
|
+
exports.default = getDocumentHeight;
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDocumentHeight = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Determine the document's height
|
|
6
3
|
*
|
|
7
4
|
* @see https://github.com/cferdinandi/smooth-scroll (credits)
|
|
8
5
|
*/
|
|
9
|
-
function getDocumentHeight() {
|
|
6
|
+
export function getDocumentHeight() {
|
|
10
7
|
var body = document.body, documentElement = document.documentElement;
|
|
11
8
|
return Math.max(body.scrollHeight, documentElement.scrollHeight, body.offsetHeight, documentElement.offsetHeight, body.clientHeight, documentElement.clientHeight);
|
|
12
9
|
}
|
|
13
|
-
|
|
14
|
-
exports.default = getDocumentHeight;
|
|
10
|
+
export default getDocumentHeight;
|
package/getHeight.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getHeight = void 0;
|
|
1
4
|
/**
|
|
2
5
|
* Get element height
|
|
3
6
|
*/
|
|
4
|
-
|
|
7
|
+
function getHeight(element) {
|
|
5
8
|
return parseInt(window.getComputedStyle(element).height, 10);
|
|
6
9
|
}
|
|
7
|
-
|
|
10
|
+
exports.getHeight = getHeight;
|
|
11
|
+
exports.default = getHeight;
|