@koine/dom 2.0.0-beta.2 → 2.0.0-beta.4
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/$$.d.ts +1 -1
- package/$$.js +19 -6
- package/$$.mjs +1 -2
- package/$.d.ts +1 -1
- package/$.js +19 -6
- package/$.mjs +1 -2
- package/$each.js +22 -17
- package/$each.mjs +3 -4
- package/_listen-delegation.d.ts +3 -2
- package/_listen-delegation.js +42 -49
- package/_listen-delegation.mjs +17 -23
- package/addClass.js +21 -10
- package/addClass.mjs +2 -5
- package/calculateFixedOffset.js +22 -9
- package/calculateFixedOffset.mjs +3 -4
- package/createElement.js +22 -15
- package/createElement.mjs +2 -3
- package/emitEvent.js +22 -12
- package/emitEvent.mjs +3 -7
- package/escapeSelector.js +19 -6
- package/escapeSelector.mjs +1 -2
- package/exists.js +19 -6
- package/exists.mjs +1 -2
- package/forEach.d.ts +4 -5
- package/forEach.js +22 -11
- package/forEach.mjs +4 -7
- package/getDataAttr.js +19 -6
- package/getDataAttr.mjs +1 -2
- package/getDocumentHeight.js +20 -7
- package/getDocumentHeight.mjs +2 -3
- package/getHeight.js +19 -6
- package/getHeight.mjs +1 -2
- package/getListeners.d.ts +1 -1
- package/getListeners.js +23 -16
- package/getListeners.mjs +4 -5
- package/getOffset.js +26 -10
- package/getOffset.mjs +8 -6
- package/getOffsetTop.js +21 -8
- package/getOffsetTop.mjs +3 -4
- package/getOffsetTopSlim.js +19 -6
- package/getOffsetTopSlim.mjs +1 -2
- package/getScrollbarWidth.js +19 -6
- package/getScrollbarWidth.mjs +1 -2
- package/getStyleValue.js +19 -6
- package/getStyleValue.mjs +1 -2
- package/getVisualBackgroundColor.js +26 -14
- package/getVisualBackgroundColor.mjs +8 -10
- package/index.js +191 -92
- package/injectCss.js +21 -10
- package/injectCss.mjs +2 -5
- package/isHidden.js +19 -6
- package/isHidden.mjs +1 -2
- package/isInViewport.js +21 -13
- package/isInViewport.mjs +3 -9
- package/isNodeList.js +21 -12
- package/isNodeList.mjs +3 -8
- package/isTotallyScrolled.js +19 -6
- package/isTotallyScrolled.mjs +1 -2
- package/listen.d.ts +2 -1
- package/listen.js +33 -25
- package/listen.mjs +11 -8
- package/listenLoaded.js +21 -12
- package/listenLoaded.mjs +2 -3
- package/listenOnce.js +24 -19
- package/listenOnce.mjs +2 -3
- package/listenResize.js +20 -11
- package/listenResize.mjs +1 -2
- package/listenResizeDebounced.js +48 -45
- package/listenResizeDebounced.mjs +28 -36
- package/listenResizeThrottled.js +21 -18
- package/listenResizeThrottled.mjs +1 -8
- package/listenScroll.js +21 -14
- package/listenScroll.mjs +2 -5
- package/listenScrollDebounced.js +21 -18
- package/listenScrollDebounced.mjs +1 -8
- package/listenScrollThrottled.js +21 -18
- package/listenScrollThrottled.mjs +1 -8
- package/off.d.ts +2 -2
- package/off.js +20 -11
- package/off.mjs +2 -5
- package/on.d.ts +2 -2
- package/on.js +25 -15
- package/on.mjs +5 -5
- package/onClickOutside.js +16 -12
- package/onClickOutside.mjs +5 -7
- package/once.js +25 -16
- package/once.mjs +3 -5
- package/package.json +12 -8
- package/removeClass.js +22 -11
- package/removeClass.mjs +3 -6
- package/scrollTo.js +31 -27
- package/scrollTo.mjs +13 -14
- package/setDataAttr.js +19 -6
- package/setDataAttr.mjs +1 -2
- package/setVendorCSS.js +20 -7
- package/setVendorCSS.mjs +2 -3
- package/siblings.js +22 -9
- package/siblings.mjs +4 -5
- package/toArray.js +19 -6
- package/toArray.mjs +1 -2
- package/types.d.ts +5 -0
- package/types.js +3 -1
- package/types.mjs +1 -1
- package/unlisten.d.ts +2 -1
- package/unlisten.js +34 -26
- package/unlisten.mjs +11 -9
- package/getVisualBackground.d.ts +0 -6
- package/getVisualBackground.js +0 -25
- package/getVisualBackground.mjs +0 -21
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Get the background color of an element eventually looking recursively into
|
|
3
3
|
* its parents, if nothing is found it returns a `#fff` background
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var transparent = "rgba(0, 0, 0, 0)";
|
|
9
|
-
var transparentIE11 = "transparent";
|
|
4
|
+
*/ export function getVisualBackgroundColor(elem) {
|
|
5
|
+
if (!elem) return "#fff";
|
|
6
|
+
const transparent = "rgba(0, 0, 0, 0)";
|
|
7
|
+
const transparentIE11 = "transparent";
|
|
10
8
|
// if (!elem) return transparent;
|
|
11
|
-
|
|
9
|
+
const bg = window.getComputedStyle(elem).backgroundColor;
|
|
12
10
|
if (bg === transparent || bg === transparentIE11) {
|
|
13
|
-
|
|
14
|
-
if (
|
|
15
|
-
return getVisualBackgroundColor(
|
|
11
|
+
const parent = elem.parentElement;
|
|
12
|
+
if (parent) {
|
|
13
|
+
return getVisualBackgroundColor(parent);
|
|
16
14
|
}
|
|
17
15
|
return "#fff";
|
|
18
16
|
}
|
package/index.js
CHANGED
|
@@ -1,93 +1,192 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
$$: function() {
|
|
13
|
+
return _$$.$$;
|
|
14
|
+
},
|
|
15
|
+
$each: function() {
|
|
16
|
+
return _$each.$each;
|
|
17
|
+
},
|
|
18
|
+
$: function() {
|
|
19
|
+
return _$.$;
|
|
20
|
+
},
|
|
21
|
+
addClass: function() {
|
|
22
|
+
return _addClass.addClass;
|
|
23
|
+
},
|
|
24
|
+
calculateFixedOffset: function() {
|
|
25
|
+
return _calculateFixedOffset.calculateFixedOffset;
|
|
26
|
+
},
|
|
27
|
+
createElement: function() {
|
|
28
|
+
return _createElement.createElement;
|
|
29
|
+
},
|
|
30
|
+
emitEvent: function() {
|
|
31
|
+
return _emitEvent.emitEvent;
|
|
32
|
+
},
|
|
33
|
+
escapeSelector: function() {
|
|
34
|
+
return _escapeSelector.escapeSelector;
|
|
35
|
+
},
|
|
36
|
+
exists: function() {
|
|
37
|
+
return _exists.exists;
|
|
38
|
+
},
|
|
39
|
+
forEach: function() {
|
|
40
|
+
return _forEach.forEach;
|
|
41
|
+
},
|
|
42
|
+
getDataAttr: function() {
|
|
43
|
+
return _getDataAttr.getDataAttr;
|
|
44
|
+
},
|
|
45
|
+
getDocumentHeight: function() {
|
|
46
|
+
return _getDocumentHeight.getDocumentHeight;
|
|
47
|
+
},
|
|
48
|
+
getHeight: function() {
|
|
49
|
+
return _getHeight.getHeight;
|
|
50
|
+
},
|
|
51
|
+
getListeners: function() {
|
|
52
|
+
return _getListeners.getListeners;
|
|
53
|
+
},
|
|
54
|
+
getOffset: function() {
|
|
55
|
+
return _getOffset.getOffset;
|
|
56
|
+
},
|
|
57
|
+
getOffsetTop: function() {
|
|
58
|
+
return _getOffsetTop.getOffsetTop;
|
|
59
|
+
},
|
|
60
|
+
getOffsetTopSlim: function() {
|
|
61
|
+
return _getOffsetTopSlim.getOffsetTopSlim;
|
|
62
|
+
},
|
|
63
|
+
getScrollbarWidth: function() {
|
|
64
|
+
return _getScrollbarWidth.getScrollbarWidth;
|
|
65
|
+
},
|
|
66
|
+
getStyleValue: function() {
|
|
67
|
+
return _getStyleValue.getStyleValue;
|
|
68
|
+
},
|
|
69
|
+
getVisualBackgroundColor: function() {
|
|
70
|
+
return _getVisualBackgroundColor.getVisualBackgroundColor;
|
|
71
|
+
},
|
|
72
|
+
injectCss: function() {
|
|
73
|
+
return _injectCss.injectCss;
|
|
74
|
+
},
|
|
75
|
+
isHidden: function() {
|
|
76
|
+
return _isHidden.isHidden;
|
|
77
|
+
},
|
|
78
|
+
isInViewport: function() {
|
|
79
|
+
return _isInViewport.isInViewport;
|
|
80
|
+
},
|
|
81
|
+
isNodeList: function() {
|
|
82
|
+
return _isNodeList.isNodeList;
|
|
83
|
+
},
|
|
84
|
+
isTotallyScrolled: function() {
|
|
85
|
+
return _isTotallyScrolled.isTotallyScrolled;
|
|
86
|
+
},
|
|
87
|
+
listenLoaded: function() {
|
|
88
|
+
return _listenLoaded.listenLoaded;
|
|
89
|
+
},
|
|
90
|
+
listenOnce: function() {
|
|
91
|
+
return _listenOnce.listenOnce;
|
|
92
|
+
},
|
|
93
|
+
listenResize: function() {
|
|
94
|
+
return _listenResize.listenResize;
|
|
95
|
+
},
|
|
96
|
+
listenResizeDebounced: function() {
|
|
97
|
+
return _listenResizeDebounced.listenResizeDebounced;
|
|
98
|
+
},
|
|
99
|
+
listenResizeThrottled: function() {
|
|
100
|
+
return _listenResizeThrottled.listenResizeThrottled;
|
|
101
|
+
},
|
|
102
|
+
listenScroll: function() {
|
|
103
|
+
return _listenScroll.listenScroll;
|
|
104
|
+
},
|
|
105
|
+
listenScrollDebounced: function() {
|
|
106
|
+
return _listenScrollDebounced.listenScrollDebounced;
|
|
107
|
+
},
|
|
108
|
+
listenScrollThrottled: function() {
|
|
109
|
+
return _listenScrollThrottled.listenScrollThrottled;
|
|
110
|
+
},
|
|
111
|
+
listen: function() {
|
|
112
|
+
return _listen.listen;
|
|
113
|
+
},
|
|
114
|
+
off: function() {
|
|
115
|
+
return _off.off;
|
|
116
|
+
},
|
|
117
|
+
once: function() {
|
|
118
|
+
return _once.once;
|
|
119
|
+
},
|
|
120
|
+
onClickOutside: function() {
|
|
121
|
+
return _onClickOutside.onClickOutside;
|
|
122
|
+
},
|
|
123
|
+
on: function() {
|
|
124
|
+
return _on.on;
|
|
125
|
+
},
|
|
126
|
+
removeClass: function() {
|
|
127
|
+
return _removeClass.removeClass;
|
|
128
|
+
},
|
|
129
|
+
scrollTo: function() {
|
|
130
|
+
return _scrollTo.scrollTo;
|
|
131
|
+
},
|
|
132
|
+
setDataAttr: function() {
|
|
133
|
+
return _setDataAttr.setDataAttr;
|
|
134
|
+
},
|
|
135
|
+
setVendorCSS: function() {
|
|
136
|
+
return _setVendorCSS.setVendorCSS;
|
|
137
|
+
},
|
|
138
|
+
siblings: function() {
|
|
139
|
+
return _siblings.siblings;
|
|
140
|
+
},
|
|
141
|
+
toArray: function() {
|
|
142
|
+
return _toArray.toArray;
|
|
143
|
+
},
|
|
144
|
+
unlisten: function() {
|
|
145
|
+
return _unlisten.unlisten;
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
const _$$ = require("./$$");
|
|
149
|
+
const _$each = require("./$each");
|
|
150
|
+
const _$ = require("./$");
|
|
151
|
+
const _addClass = require("./addClass");
|
|
152
|
+
const _calculateFixedOffset = require("./calculateFixedOffset");
|
|
153
|
+
const _createElement = require("./createElement");
|
|
154
|
+
const _emitEvent = require("./emitEvent");
|
|
155
|
+
const _escapeSelector = require("./escapeSelector");
|
|
156
|
+
const _exists = require("./exists");
|
|
157
|
+
const _forEach = require("./forEach");
|
|
158
|
+
const _getDataAttr = require("./getDataAttr");
|
|
159
|
+
const _getDocumentHeight = require("./getDocumentHeight");
|
|
160
|
+
const _getHeight = require("./getHeight");
|
|
161
|
+
const _getListeners = require("./getListeners");
|
|
162
|
+
const _getOffset = require("./getOffset");
|
|
163
|
+
const _getOffsetTop = require("./getOffsetTop");
|
|
164
|
+
const _getOffsetTopSlim = require("./getOffsetTopSlim");
|
|
165
|
+
const _getScrollbarWidth = require("./getScrollbarWidth");
|
|
166
|
+
const _getStyleValue = require("./getStyleValue");
|
|
167
|
+
const _getVisualBackgroundColor = require("./getVisualBackgroundColor");
|
|
168
|
+
const _injectCss = require("./injectCss");
|
|
169
|
+
const _isHidden = require("./isHidden");
|
|
170
|
+
const _isInViewport = require("./isInViewport");
|
|
171
|
+
const _isNodeList = require("./isNodeList");
|
|
172
|
+
const _isTotallyScrolled = require("./isTotallyScrolled");
|
|
173
|
+
const _listenLoaded = require("./listenLoaded");
|
|
174
|
+
const _listenOnce = require("./listenOnce");
|
|
175
|
+
const _listenResize = require("./listenResize");
|
|
176
|
+
const _listenResizeDebounced = require("./listenResizeDebounced");
|
|
177
|
+
const _listenResizeThrottled = require("./listenResizeThrottled");
|
|
178
|
+
const _listenScroll = require("./listenScroll");
|
|
179
|
+
const _listenScrollDebounced = require("./listenScrollDebounced");
|
|
180
|
+
const _listenScrollThrottled = require("./listenScrollThrottled");
|
|
181
|
+
const _listen = require("./listen");
|
|
182
|
+
const _off = require("./off");
|
|
183
|
+
const _once = require("./once");
|
|
184
|
+
const _onClickOutside = require("./onClickOutside");
|
|
185
|
+
const _on = require("./on");
|
|
186
|
+
const _removeClass = require("./removeClass");
|
|
187
|
+
const _scrollTo = require("./scrollTo");
|
|
188
|
+
const _setDataAttr = require("./setDataAttr");
|
|
189
|
+
const _setVendorCSS = require("./setVendorCSS");
|
|
190
|
+
const _siblings = require("./siblings");
|
|
191
|
+
const _toArray = require("./toArray");
|
|
192
|
+
const _unlisten = require("./unlisten");
|
package/injectCss.js
CHANGED
|
@@ -1,13 +1,25 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.injectCss = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Inject css
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
*/ "use strict";
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
function _export(target, all) {
|
|
8
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: all[name]
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
_export(exports, {
|
|
14
|
+
injectCss: function() {
|
|
15
|
+
return injectCss;
|
|
16
|
+
},
|
|
17
|
+
default: function() {
|
|
18
|
+
return _default;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
function injectCss(id, cssString = "", root = document) {
|
|
22
|
+
let styleblock;
|
|
11
23
|
styleblock = root.getElementById(id);
|
|
12
24
|
if (!styleblock) {
|
|
13
25
|
styleblock = root.createElement("style");
|
|
@@ -16,5 +28,4 @@ function injectCss(id, cssString, root) {
|
|
|
16
28
|
}
|
|
17
29
|
styleblock.innerHTML = cssString;
|
|
18
30
|
}
|
|
19
|
-
|
|
20
|
-
exports.default = injectCss;
|
|
31
|
+
const _default = injectCss;
|
package/injectCss.mjs
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Inject css
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
if (cssString === void 0) { cssString = ""; }
|
|
6
|
-
if (root === void 0) { root = document; }
|
|
7
|
-
var styleblock;
|
|
3
|
+
*/ export function injectCss(id, cssString = "", root = document) {
|
|
4
|
+
let styleblock;
|
|
8
5
|
styleblock = root.getElementById(id);
|
|
9
6
|
if (!styleblock) {
|
|
10
7
|
styleblock = root.createElement("style");
|
package/isHidden.js
CHANGED
|
@@ -1,11 +1,24 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isHidden = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Is element hidden?
|
|
6
|
-
*/
|
|
3
|
+
*/ "use strict";
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
function _export(target, all) {
|
|
8
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: all[name]
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
_export(exports, {
|
|
14
|
+
isHidden: function() {
|
|
15
|
+
return isHidden;
|
|
16
|
+
},
|
|
17
|
+
default: function() {
|
|
18
|
+
return _default;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
7
21
|
function isHidden(el) {
|
|
8
22
|
return !el || el.offsetParent === null;
|
|
9
23
|
}
|
|
10
|
-
|
|
11
|
-
exports.default = isHidden;
|
|
24
|
+
const _default = isHidden;
|
package/isHidden.mjs
CHANGED
package/isInViewport.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isInViewport = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Determine if an element is in the viewport
|
|
6
3
|
*
|
|
@@ -8,15 +5,26 @@ exports.isInViewport = void 0;
|
|
|
8
5
|
*
|
|
9
6
|
* @param elem The element
|
|
10
7
|
* @return Returns true if element is in the viewport
|
|
11
|
-
*/
|
|
8
|
+
*/ "use strict";
|
|
9
|
+
Object.defineProperty(exports, "__esModule", {
|
|
10
|
+
value: true
|
|
11
|
+
});
|
|
12
|
+
function _export(target, all) {
|
|
13
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: all[name]
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
_export(exports, {
|
|
19
|
+
isInViewport: function() {
|
|
20
|
+
return isInViewport;
|
|
21
|
+
},
|
|
22
|
+
default: function() {
|
|
23
|
+
return _default;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
12
26
|
function isInViewport(elem) {
|
|
13
|
-
|
|
14
|
-
return
|
|
15
|
-
distance.left >= 0 &&
|
|
16
|
-
distance.bottom <=
|
|
17
|
-
(window.innerHeight || document.documentElement.clientHeight) &&
|
|
18
|
-
distance.right <=
|
|
19
|
-
(window.innerWidth || document.documentElement.clientWidth));
|
|
27
|
+
const distance = elem.getBoundingClientRect();
|
|
28
|
+
return distance.top >= 0 && distance.left >= 0 && distance.bottom <= (window.innerHeight || document.documentElement.clientHeight) && distance.right <= (window.innerWidth || document.documentElement.clientWidth);
|
|
20
29
|
}
|
|
21
|
-
|
|
22
|
-
exports.default = isInViewport;
|
|
30
|
+
const _default = isInViewport;
|
package/isInViewport.mjs
CHANGED
|
@@ -5,14 +5,8 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @param elem The element
|
|
7
7
|
* @return Returns true if element is in the viewport
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return (distance.top >= 0 &&
|
|
12
|
-
distance.left >= 0 &&
|
|
13
|
-
distance.bottom <=
|
|
14
|
-
(window.innerHeight || document.documentElement.clientHeight) &&
|
|
15
|
-
distance.right <=
|
|
16
|
-
(window.innerWidth || document.documentElement.clientWidth));
|
|
8
|
+
*/ export function isInViewport(elem) {
|
|
9
|
+
const distance = elem.getBoundingClientRect();
|
|
10
|
+
return distance.top >= 0 && distance.left >= 0 && distance.bottom <= (window.innerHeight || document.documentElement.clientHeight) && distance.right <= (window.innerWidth || document.documentElement.clientWidth);
|
|
17
11
|
}
|
|
18
12
|
export default isInViewport;
|
package/isNodeList.js
CHANGED
|
@@ -1,18 +1,27 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isNodeList = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Is node list
|
|
6
3
|
*
|
|
7
4
|
* @param nodes The object to check
|
|
8
|
-
*/
|
|
5
|
+
*/ "use strict";
|
|
6
|
+
Object.defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
function _export(target, all) {
|
|
10
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: all[name]
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
_export(exports, {
|
|
16
|
+
isNodeList: function() {
|
|
17
|
+
return isNodeList;
|
|
18
|
+
},
|
|
19
|
+
default: function() {
|
|
20
|
+
return _default;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
9
23
|
function isNodeList(nodes) {
|
|
10
|
-
|
|
11
|
-
return (typeof nodes === "object" &&
|
|
12
|
-
/^\[object (HTMLCollection|NodeList|Object)\]$/.test(stringRepr) &&
|
|
13
|
-
typeof nodes.length === "number" &&
|
|
14
|
-
(nodes.length === 0 ||
|
|
15
|
-
(typeof nodes[0] === "object" && nodes[0].nodeType > 0)));
|
|
24
|
+
const stringRepr = Object.prototype.toString.call(nodes);
|
|
25
|
+
return typeof nodes === "object" && /^\[object (HTMLCollection|NodeList|Object)\]$/.test(stringRepr) && typeof nodes.length === "number" && (nodes.length === 0 || typeof nodes[0] === "object" && nodes[0].nodeType > 0);
|
|
16
26
|
}
|
|
17
|
-
|
|
18
|
-
exports.default = isNodeList;
|
|
27
|
+
const _default = isNodeList;
|
package/isNodeList.mjs
CHANGED
|
@@ -2,13 +2,8 @@
|
|
|
2
2
|
* Is node list
|
|
3
3
|
*
|
|
4
4
|
* @param nodes The object to check
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return (typeof nodes === "object" &&
|
|
9
|
-
/^\[object (HTMLCollection|NodeList|Object)\]$/.test(stringRepr) &&
|
|
10
|
-
typeof nodes.length === "number" &&
|
|
11
|
-
(nodes.length === 0 ||
|
|
12
|
-
(typeof nodes[0] === "object" && nodes[0].nodeType > 0)));
|
|
5
|
+
*/ export function isNodeList(nodes) {
|
|
6
|
+
const stringRepr = Object.prototype.toString.call(nodes);
|
|
7
|
+
return typeof nodes === "object" && /^\[object (HTMLCollection|NodeList|Object)\]$/.test(stringRepr) && typeof nodes.length === "number" && (nodes.length === 0 || typeof nodes[0] === "object" && nodes[0].nodeType > 0);
|
|
13
8
|
}
|
|
14
9
|
export default isNodeList;
|
package/isTotallyScrolled.js
CHANGED
|
@@ -1,14 +1,27 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isTotallyScrolled = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Is element totally scrolled
|
|
6
3
|
*
|
|
7
4
|
* @see https://github.com/willmcpo/body-scroll-lock/blob/master/src/bodyScrollLock.js#L116
|
|
8
5
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight#Problems_and_solutions
|
|
9
|
-
*/
|
|
6
|
+
*/ "use strict";
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
function _export(target, all) {
|
|
11
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: all[name]
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
_export(exports, {
|
|
17
|
+
isTotallyScrolled: function() {
|
|
18
|
+
return isTotallyScrolled;
|
|
19
|
+
},
|
|
20
|
+
default: function() {
|
|
21
|
+
return _default;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
10
24
|
function isTotallyScrolled(el) {
|
|
11
25
|
return el ? el.scrollHeight - el.scrollTop <= el.clientHeight : false;
|
|
12
26
|
}
|
|
13
|
-
|
|
14
|
-
exports.default = isTotallyScrolled;
|
|
27
|
+
const _default = isTotallyScrolled;
|
package/isTotallyScrolled.mjs
CHANGED
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @see https://github.com/willmcpo/body-scroll-lock/blob/master/src/bodyScrollLock.js#L116
|
|
5
5
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight#Problems_and_solutions
|
|
6
|
-
*/
|
|
7
|
-
export function isTotallyScrolled(el) {
|
|
6
|
+
*/ export function isTotallyScrolled(el) {
|
|
8
7
|
return el ? el.scrollHeight - el.scrollTop <= el.clientHeight : false;
|
|
9
8
|
}
|
|
10
9
|
export default isTotallyScrolled;
|
package/listen.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type EventCallback } from "./_listen-delegation";
|
|
2
|
+
import type { AnyDOMEventTarget, AnyDOMEventType } from "./types";
|
|
2
3
|
/**
|
|
3
4
|
* Listen an event
|
|
4
5
|
*
|
|
@@ -8,5 +9,5 @@ import { type EventCallback } from "./_listen-delegation";
|
|
|
8
9
|
* @param selector The selector to run the event on
|
|
9
10
|
* @param callback The function to run when the event fires
|
|
10
11
|
*/
|
|
11
|
-
export declare function listen(types:
|
|
12
|
+
export declare function listen<TTypes extends AnyDOMEventType, TTarget extends AnyDOMEventTarget = AnyDOMEventTarget>(types: TTypes, selector: string, callback: EventCallback<TTarget, TTypes>): void;
|
|
12
13
|
export default listen;
|