@wikicasa-dev/utilities 1.1.8 → 1.1.10
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/dist/ObserverUtils.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function u(
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function u(t,s,l){const i=[].slice.call(typeof t=="string"?document.querySelectorAll(t):[t]),b=new IntersectionObserver((e,o)=>{for(let n=0;n<e.length;n++){const r=e[n];if(r.isIntersecting){const c=r.target;s(c,o),o.unobserve(c)}}},l);i.forEach(e=>{b.observe(e)})}exports.observeOnce=u;
|
package/dist/ObserverUtils.js
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
function
|
|
2
|
-
const i = [].slice.call(
|
|
3
|
-
|
|
1
|
+
function b(n, s, l) {
|
|
2
|
+
const i = [].slice.call(
|
|
3
|
+
typeof n == "string" ? document.querySelectorAll(n) : [n]
|
|
4
|
+
), f = new IntersectionObserver(
|
|
5
|
+
(e, o) => {
|
|
4
6
|
for (let t = 0; t < e.length; t++) {
|
|
5
|
-
const
|
|
6
|
-
if (
|
|
7
|
-
const c =
|
|
8
|
-
s(c,
|
|
7
|
+
const r = e[t];
|
|
8
|
+
if (r.isIntersecting) {
|
|
9
|
+
const c = r.target;
|
|
10
|
+
s(c, o), o.unobserve(c);
|
|
9
11
|
}
|
|
10
12
|
}
|
|
11
13
|
},
|
|
12
14
|
l
|
|
13
15
|
);
|
|
14
16
|
i.forEach((e) => {
|
|
15
|
-
|
|
17
|
+
f.observe(e);
|
|
16
18
|
});
|
|
17
19
|
}
|
|
18
20
|
export {
|
|
19
|
-
|
|
21
|
+
b as observeOnce
|
|
20
22
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Observes if an element is visible in the viewport. Once it is visible, the listener is removed
|
|
3
3
|
* */
|
|
4
|
-
export declare function observeOnce(selector: string, fn: (Element: Node, IntersectionObserver: IntersectionObserver) => void, options?: IntersectionObserverInit): void;
|
|
4
|
+
export declare function observeOnce(selector: string | HTMLElement, fn: (Element: Node, IntersectionObserver: IntersectionObserver) => void, options?: IntersectionObserverInit): void;
|