drab 6.5.1 → 7.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/dist/announcer/index.d.ts +2 -0
- package/dist/base/index.d.ts +101 -1536
- package/dist/base/index.js +87 -76
- package/dist/contextmenu/index.d.ts +1045 -3
- package/dist/contextmenu/index.js +15 -15
- package/dist/define.d.ts +11 -1
- package/dist/define.js +11 -5
- package/dist/dialog/index.d.ts +1047 -6
- package/dist/dialog/index.js +22 -22
- package/dist/editor/index.d.ts +1047 -12
- package/dist/editor/index.js +36 -36
- package/dist/fullscreen/index.d.ts +1045 -7
- package/dist/fullscreen/index.js +8 -8
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -3
- package/dist/intersect/index.d.ts +1059 -16
- package/dist/intersect/index.js +26 -33
- package/dist/prefetch/index.d.ts +706 -25
- package/dist/prefetch/index.js +25 -44
- package/dist/share/index.d.ts +1413 -11
- package/dist/share/index.js +50 -18
- package/dist/tablesort/index.d.ts +1390 -5
- package/dist/tablesort/index.js +5 -5
- package/dist/tabs/index.d.ts +702 -4
- package/dist/tabs/index.js +3 -3
- package/dist/types/index.d.ts +29 -0
- package/dist/wakelock/index.d.ts +1390 -6
- package/dist/wakelock/index.js +16 -16
- package/package.json +5 -24
- package/dist/base/define.js +0 -3
- package/dist/copy/define.d.ts +0 -1
- package/dist/copy/define.js +0 -3
- package/dist/copy/index.d.ts +0 -30
- package/dist/copy/index.js +0 -39
- package/dist/youtube/define.d.ts +0 -1
- package/dist/youtube/define.js +0 -3
- package/dist/youtube/index.d.ts +0 -31
- package/dist/youtube/index.js +0 -56
- /package/dist/{base/define.d.ts → types/index.js} +0 -0
package/dist/intersect/index.js
CHANGED
@@ -1,64 +1,57 @@
|
|
1
|
-
import {
|
1
|
+
import { Content, Lifecycle, Trigger, } from "../base/index.js";
|
2
2
|
/**
|
3
|
-
* Uses the
|
3
|
+
* Uses the
|
4
|
+
* [Intersection Observer API](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API)
|
5
|
+
* to add a `data-intersect` attribute to `content` when the `trigger` is intersecting.
|
4
6
|
*
|
5
|
-
*
|
7
|
+
* ### Events
|
8
|
+
*
|
9
|
+
* `intersect`
|
10
|
+
*
|
11
|
+
* Fired when the `trigger` enters the viewport.
|
12
|
+
*
|
13
|
+
* `exit`
|
14
|
+
*
|
15
|
+
* Fired when the `trigger` exits the viewport.
|
6
16
|
*
|
7
17
|
* ### Attributes
|
8
18
|
*
|
9
19
|
* `threshold`
|
10
20
|
*
|
11
|
-
* Specify a `threshold` between `0` and `1` to determine how much of the
|
21
|
+
* Specify a `threshold` between `0` and `1` to determine how much of the
|
22
|
+
* `trigger` should be visible for the intersection to occur.
|
12
23
|
*/
|
13
|
-
export class Intersect extends
|
14
|
-
/** Functions to run when the `trigger` intersects. */
|
15
|
-
#intersectCallbacks = [];
|
16
|
-
/** Functions to run when the `trigger` exits. */
|
17
|
-
#exitCallbacks = [];
|
24
|
+
export class Intersect extends Lifecycle(Trigger(Content())) {
|
18
25
|
constructor() {
|
19
26
|
super();
|
20
27
|
}
|
21
28
|
/**
|
22
|
-
* How much of the `trigger` should be visible for the intersection to occur.
|
29
|
+
* How much of the `trigger` should be visible for the intersection to occur.
|
30
|
+
* For example, given a threshold of `.5`, the intersection would occur when
|
31
|
+
* the `trigger` is 50% visible.
|
23
32
|
*
|
24
33
|
* @default 0
|
25
34
|
*/
|
26
35
|
get #threshold() {
|
27
36
|
return Number(this.getAttribute("threshold") ?? 0);
|
28
37
|
}
|
29
|
-
/**
|
30
|
-
* @param callback Runs when `trigger` intersects.
|
31
|
-
*/
|
32
|
-
onIntersect(callback) {
|
33
|
-
this.#intersectCallbacks.push(callback);
|
34
|
-
}
|
35
|
-
/**
|
36
|
-
* @param callback Runs when `trigger` exits.
|
37
|
-
*/
|
38
|
-
onExit(callback) {
|
39
|
-
this.#exitCallbacks.push(callback);
|
40
|
-
}
|
41
38
|
mount() {
|
42
39
|
const observer = new IntersectionObserver((entries) => {
|
43
|
-
|
40
|
+
// attribute to add or remove from `content`
|
44
41
|
const attr = "data-intersect";
|
45
42
|
for (const entry of entries) {
|
46
43
|
if (entry.isIntersecting) {
|
47
|
-
this.
|
48
|
-
for (const callback of this.#intersectCallbacks) {
|
49
|
-
callback();
|
50
|
-
}
|
44
|
+
this.content().setAttribute(attr, "");
|
51
45
|
}
|
52
46
|
else {
|
53
|
-
this.
|
54
|
-
for (const callback of this.#exitCallbacks) {
|
55
|
-
callback();
|
56
|
-
}
|
47
|
+
this.content().removeAttribute(attr);
|
57
48
|
}
|
49
|
+
this.dispatchEvent(new CustomEvent(entry.isIntersecting ? "intersect" : "exit", {
|
50
|
+
detail: { entry },
|
51
|
+
}));
|
58
52
|
}
|
59
53
|
}, { threshold: this.#threshold });
|
60
|
-
for (const trigger of this.
|
54
|
+
for (const trigger of this.triggers())
|
61
55
|
observer.observe(trigger);
|
62
|
-
}
|
63
56
|
}
|
64
57
|
}
|