vlite3 1.5.37 → 1.5.38
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/components/Carousel/Carousel.vue.js +2 -2
- package/components/Carousel/Carousel2.vue.js +38 -31
- package/directives/ScrollReveal/ScrollRevealContainer.d.ts +43 -0
- package/directives/ScrollReveal/ScrollRevealContainer.js +88 -0
- package/directives/ScrollReveal/ScrollRevealMotion.d.ts +16 -0
- package/directives/ScrollReveal/ScrollRevealMotion.js +91 -0
- package/directives/ScrollReveal/ScrollRevealOptions.d.ts +19 -0
- package/directives/ScrollReveal/ScrollRevealOptions.js +34 -0
- package/directives/ScrollReveal/ScrollRevealPager.d.ts +33 -0
- package/directives/ScrollReveal/ScrollRevealPager.js +239 -0
- package/directives/vScrollReveal.d.ts +5 -2
- package/directives/vScrollReveal.js +18 -47
- package/docs/ScrollRevealMigrationAudit.md +227 -0
- package/docs/component-index.md +4 -2
- package/docs/components/carousel.md +1 -1
- package/docs/components/scroll-reveal.md +178 -0
- package/docs-manifest.json +10 -4
- package/package.json +1 -3
- package/style.css +7 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import o from "./Carousel2.vue.js";
|
|
2
2
|
/* empty css */
|
|
3
3
|
import r from "../../_virtual/_plugin-vue_export-helper.js";
|
|
4
|
-
const
|
|
4
|
+
const m = /* @__PURE__ */ r(o, [["__scopeId", "data-v-a6f69bd0"]]);
|
|
5
5
|
export {
|
|
6
|
-
|
|
6
|
+
m as default
|
|
7
7
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { defineComponent as
|
|
1
|
+
import { defineComponent as x, shallowRef as w, computed as o, openBlock as T, createElementBlock as b, createVNode as N, unref as C, mergeProps as z, createSlots as K, renderList as _, withCtx as k, renderSlot as G, normalizeProps as R, guardReactiveProps as E } from "vue";
|
|
2
2
|
import I from "vue-carousel-lite";
|
|
3
3
|
import "vue-carousel-lite/style.css";
|
|
4
|
-
const
|
|
4
|
+
const L = /* @__PURE__ */ x({
|
|
5
5
|
__name: "Carousel",
|
|
6
6
|
props: {
|
|
7
7
|
data: { default: () => [] },
|
|
@@ -37,48 +37,55 @@ const V = { class: "carousel-wrapper" }, $ = /* @__PURE__ */ S({
|
|
|
37
37
|
updateKey: { default: void 0 }
|
|
38
38
|
},
|
|
39
39
|
emits: ["slide-change"],
|
|
40
|
-
setup(
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
setup(s, { expose: u, emit: i }) {
|
|
41
|
+
const l = s;
|
|
42
|
+
function d(e) {
|
|
43
|
+
(e.ctrlKey || e.metaKey || e.altKey || e.shiftKey || l.direction === "horizontal" && Math.abs(e.deltaY) >= Math.abs(e.deltaX)) && e.stopPropagation();
|
|
44
|
+
}
|
|
45
|
+
const f = i, t = w(null), p = (e, a) => {
|
|
46
|
+
t.value?.goToSlide(e, a);
|
|
45
47
|
}, c = (e) => {
|
|
46
|
-
t.value?.
|
|
48
|
+
t.value?.goNext(e);
|
|
47
49
|
}, g = (e) => {
|
|
48
|
-
t.value?.
|
|
50
|
+
t.value?.goPrev(e);
|
|
49
51
|
}, m = (e) => {
|
|
52
|
+
t.value?.goNextPage(e);
|
|
53
|
+
}, h = (e) => {
|
|
50
54
|
t.value?.goPrevPage(e);
|
|
51
|
-
},
|
|
55
|
+
}, y = () => {
|
|
52
56
|
t.value?.focus?.();
|
|
53
|
-
},
|
|
54
|
-
return
|
|
55
|
-
goToSlide:
|
|
56
|
-
goNext:
|
|
57
|
-
goPrev:
|
|
58
|
-
goNextPage:
|
|
59
|
-
goPrevPage:
|
|
60
|
-
focus:
|
|
61
|
-
state:
|
|
57
|
+
}, v = o(() => t.value?.state), P = o(() => t.value?.canGoNext ?? !0), B = o(() => t.value?.canGoPrev ?? !1);
|
|
58
|
+
return u({
|
|
59
|
+
goToSlide: p,
|
|
60
|
+
goNext: c,
|
|
61
|
+
goPrev: g,
|
|
62
|
+
goNextPage: m,
|
|
63
|
+
goPrevPage: h,
|
|
64
|
+
focus: y,
|
|
65
|
+
state: v,
|
|
62
66
|
canGoNext: P,
|
|
63
|
-
canGoPrev:
|
|
64
|
-
}), (e,
|
|
65
|
-
|
|
67
|
+
canGoPrev: B
|
|
68
|
+
}), (e, a) => (T(), b("div", {
|
|
69
|
+
class: "carousel-wrapper",
|
|
70
|
+
onWheelCapture: d
|
|
71
|
+
}, [
|
|
72
|
+
N(C(I), z({
|
|
66
73
|
ref_key: "carouselRef",
|
|
67
74
|
ref: t
|
|
68
|
-
},
|
|
75
|
+
}, l, {
|
|
69
76
|
style: { height: "100%", width: "100%" },
|
|
70
|
-
onSlideChange:
|
|
71
|
-
}),
|
|
72
|
-
|
|
73
|
-
name:
|
|
74
|
-
fn:
|
|
75
|
-
G(e.$slots,
|
|
77
|
+
onSlideChange: a[0] || (a[0] = (n) => f("slide-change", n))
|
|
78
|
+
}), K({ _: 2 }, [
|
|
79
|
+
_(e.$slots, (n, r) => ({
|
|
80
|
+
name: r,
|
|
81
|
+
fn: k((S) => [
|
|
82
|
+
G(e.$slots, r, R(E(S || {})), void 0, !0)
|
|
76
83
|
])
|
|
77
84
|
}))
|
|
78
85
|
]), 1040)
|
|
79
|
-
]));
|
|
86
|
+
], 32));
|
|
80
87
|
}
|
|
81
88
|
});
|
|
82
89
|
export {
|
|
83
|
-
|
|
90
|
+
L as default
|
|
84
91
|
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ScrollRevealOptions } from './ScrollRevealOptions';
|
|
2
|
+
type Registration = {
|
|
3
|
+
snap: boolean;
|
|
4
|
+
options: Required<ScrollRevealOptions>;
|
|
5
|
+
};
|
|
6
|
+
export interface ScrollRevealContext {
|
|
7
|
+
container: HTMLElement;
|
|
8
|
+
documentRoot: boolean;
|
|
9
|
+
reducedMotion: MediaQueryList;
|
|
10
|
+
finePointer: MediaQueryList;
|
|
11
|
+
position: () => number;
|
|
12
|
+
limit: () => number;
|
|
13
|
+
padding: () => number;
|
|
14
|
+
viewport: () => {
|
|
15
|
+
top: number;
|
|
16
|
+
bottom: number;
|
|
17
|
+
};
|
|
18
|
+
write: (position: number) => void;
|
|
19
|
+
canReveal: () => boolean;
|
|
20
|
+
syncNavigation: () => void;
|
|
21
|
+
}
|
|
22
|
+
export declare function resolveScrollRevealContainer(element: HTMLElement): HTMLElement;
|
|
23
|
+
export declare function getScrollRevealContainer(element: HTMLElement): ScrollRevealContainer;
|
|
24
|
+
/** One lifetime, resource policy and pair of internal engines per actual scroller. */
|
|
25
|
+
export declare class ScrollRevealContainer {
|
|
26
|
+
readonly context: ScrollRevealContext;
|
|
27
|
+
private registrations;
|
|
28
|
+
private motion;
|
|
29
|
+
private pager;
|
|
30
|
+
private lifetime;
|
|
31
|
+
private suppressRevealUntil;
|
|
32
|
+
private href;
|
|
33
|
+
constructor(container: HTMLElement);
|
|
34
|
+
register(element: HTMLElement, registration: Registration): void;
|
|
35
|
+
unregister(element: HTMLElement): void;
|
|
36
|
+
private onChange;
|
|
37
|
+
private syncNavigation;
|
|
38
|
+
private onNavigation;
|
|
39
|
+
private onFocus;
|
|
40
|
+
private showHash;
|
|
41
|
+
private onClick;
|
|
42
|
+
}
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { ScrollRevealMotion as g } from "./ScrollRevealMotion.js";
|
|
2
|
+
import { ScrollRevealPager as p } from "./ScrollRevealPager.js";
|
|
3
|
+
import { sameScrollReveal as u } from "./ScrollRevealOptions.js";
|
|
4
|
+
const l = /* @__PURE__ */ new WeakMap();
|
|
5
|
+
function m(r) {
|
|
6
|
+
for (let e = r.parentElement; e && e !== document.body && e !== document.documentElement; e = e.parentElement)
|
|
7
|
+
if (/^(auto|scroll|overlay)$/.test(getComputedStyle(e).overflowY) && e.scrollHeight > e.clientHeight) return e;
|
|
8
|
+
return document.scrollingElement || document.documentElement;
|
|
9
|
+
}
|
|
10
|
+
function E(r) {
|
|
11
|
+
const e = m(r);
|
|
12
|
+
let t = l.get(e);
|
|
13
|
+
return t || (t = new f(e), l.set(e, t)), t;
|
|
14
|
+
}
|
|
15
|
+
class f {
|
|
16
|
+
context;
|
|
17
|
+
registrations = /* @__PURE__ */ new Map();
|
|
18
|
+
motion;
|
|
19
|
+
pager;
|
|
20
|
+
lifetime = new AbortController();
|
|
21
|
+
suppressRevealUntil = 0;
|
|
22
|
+
href = window.location.href;
|
|
23
|
+
constructor(e) {
|
|
24
|
+
const t = e === document.scrollingElement || e === document.documentElement, o = window.matchMedia("(prefers-reduced-motion: reduce)"), d = window.matchMedia("(hover: hover) and (pointer: fine)"), s = navigator, h = s.connection, c = () => {
|
|
25
|
+
if (t) return { top: 0, bottom: window.innerHeight };
|
|
26
|
+
const i = e.getBoundingClientRect().top + e.clientTop;
|
|
27
|
+
return { top: i, bottom: i + e.clientHeight };
|
|
28
|
+
};
|
|
29
|
+
this.context = {
|
|
30
|
+
container: e,
|
|
31
|
+
documentRoot: t,
|
|
32
|
+
reducedMotion: o,
|
|
33
|
+
finePointer: d,
|
|
34
|
+
viewport: c,
|
|
35
|
+
syncNavigation: this.syncNavigation,
|
|
36
|
+
position: () => e.scrollTop,
|
|
37
|
+
limit: () => Math.max(0, e.scrollHeight - (t ? window.innerHeight : e.clientHeight)),
|
|
38
|
+
padding: () => {
|
|
39
|
+
const i = getComputedStyle(e).scrollPaddingTop;
|
|
40
|
+
return i.endsWith("%") ? parseFloat(i) / 100 * (c().bottom - c().top) : parseFloat(i) || 0;
|
|
41
|
+
},
|
|
42
|
+
write: (i) => e.scrollTo({ top: i, behavior: "instant" }),
|
|
43
|
+
canReveal: () => performance.now() >= this.suppressRevealUntil && !o.matches && !document.hidden && !h?.saveData && !/^(slow-)?2g$/.test(h?.effectiveType ?? "") && !(s.hardwareConcurrency > 0 && s.hardwareConcurrency <= 4) && !(s.deviceMemory !== void 0 && s.deviceMemory <= 4)
|
|
44
|
+
}, this.motion = new g(this.context), this.pager = new p(this.context);
|
|
45
|
+
const n = { signal: this.lifetime.signal }, a = t ? document : e;
|
|
46
|
+
a.addEventListener("focusin", this.onFocus, n), a.addEventListener("click", this.onClick, { ...n, capture: !0 }), a.addEventListener("pointerdown", this.pager.reset, { ...n, capture: !0 }), a.addEventListener("touchstart", this.pager.reset, { ...n, capture: !0, passive: !0 });
|
|
47
|
+
for (const i of ["hashchange", "popstate", "pageshow", "pagehide"]) window.addEventListener(i, this.onNavigation, n);
|
|
48
|
+
window.addEventListener("resize", this.onChange, n), window.addEventListener("blur", this.onChange, n), document.addEventListener("visibilitychange", this.onChange, n), o.addEventListener("change", this.onChange, n), d.addEventListener("change", this.onChange, n), h?.addEventListener("change", this.onChange, n);
|
|
49
|
+
}
|
|
50
|
+
register(e, t) {
|
|
51
|
+
this.syncNavigation();
|
|
52
|
+
const o = this.registrations.get(e);
|
|
53
|
+
o && o.snap === t.snap && u(o.options, t.options) || (o?.snap !== t.snap && (o?.snap ? this.pager.unregister(e) : o && this.motion.unregister(e)), this.registrations.set(e, t), t.snap ? o?.snap || this.pager.register(e) : this.motion.register(e, t.options), this.showHash());
|
|
54
|
+
}
|
|
55
|
+
unregister(e) {
|
|
56
|
+
const t = this.registrations.get(e);
|
|
57
|
+
t && (t.snap ? this.pager.unregister(e) : this.motion.unregister(e), this.registrations.delete(e), this.pager.reset(), !this.registrations.size && (this.lifetime.abort(), this.motion.destroy(), this.pager.destroy(), l.delete(this.context.container)));
|
|
58
|
+
}
|
|
59
|
+
onChange = () => {
|
|
60
|
+
this.pager.reset(), this.motion.refresh();
|
|
61
|
+
};
|
|
62
|
+
syncNavigation = () => {
|
|
63
|
+
this.href !== window.location.href && this.onNavigation();
|
|
64
|
+
};
|
|
65
|
+
onNavigation = () => {
|
|
66
|
+
this.href = window.location.href, this.suppressRevealUntil = performance.now() + 500, this.onChange(), this.showHash();
|
|
67
|
+
};
|
|
68
|
+
onFocus = (e) => {
|
|
69
|
+
this.pager.reset(), e.target instanceof Node && this.motion.show(e.target);
|
|
70
|
+
};
|
|
71
|
+
showHash(e = window.location.hash) {
|
|
72
|
+
if (!(!e || e === "#"))
|
|
73
|
+
try {
|
|
74
|
+
const t = document.getElementById(decodeURIComponent(e.slice(1)));
|
|
75
|
+
t && this.motion.show(t, !0);
|
|
76
|
+
} catch {
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
onClick = (e) => {
|
|
80
|
+
const t = e.composedPath().find((o) => o instanceof HTMLAnchorElement);
|
|
81
|
+
!t || t.origin !== location.origin || t.pathname !== location.pathname || t.search !== location.search || !t.hash || (this.pager.reset(), this.showHash(t.hash));
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
export {
|
|
85
|
+
f as ScrollRevealContainer,
|
|
86
|
+
E as getScrollRevealContainer,
|
|
87
|
+
m as resolveScrollRevealContainer
|
|
88
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ScrollRevealContext } from './ScrollRevealContainer';
|
|
2
|
+
import { ScrollRevealOptions } from './ScrollRevealOptions';
|
|
3
|
+
/** Visible DOM is the resting state; only an entering element receives keyframes. */
|
|
4
|
+
export declare class ScrollRevealMotion {
|
|
5
|
+
private records;
|
|
6
|
+
private observer?;
|
|
7
|
+
private context;
|
|
8
|
+
constructor(context: ScrollRevealContext);
|
|
9
|
+
register(element: HTMLElement, options: Required<ScrollRevealOptions>): void;
|
|
10
|
+
unregister(element: HTMLElement): void;
|
|
11
|
+
private cancel;
|
|
12
|
+
show(target: Node, descendants?: boolean): void;
|
|
13
|
+
refresh(): void;
|
|
14
|
+
private onEntries;
|
|
15
|
+
destroy(): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
class R {
|
|
2
|
+
records = /* @__PURE__ */ new Map();
|
|
3
|
+
observer;
|
|
4
|
+
context;
|
|
5
|
+
constructor(e) {
|
|
6
|
+
this.context = e, !(typeof IntersectionObserver > "u" || typeof Element.prototype.animate != "function") && (this.observer = new IntersectionObserver(this.onEntries, {
|
|
7
|
+
root: e.documentRoot ? null : e.container,
|
|
8
|
+
threshold: Array.from({ length: 101 }, (s, t) => t / 100)
|
|
9
|
+
}));
|
|
10
|
+
}
|
|
11
|
+
register(e, s) {
|
|
12
|
+
const t = this.records.get(e);
|
|
13
|
+
this.cancel(t);
|
|
14
|
+
const o = e.getBoundingClientRect(), i = this.context.viewport(), n = t?.seen ?? o.top < i.bottom;
|
|
15
|
+
this.records.set(e, { options: s, seen: n, entered: t?.entered ?? !!n }), this.observer && (s.reset || !n) ? this.observer.observe(e) : this.observer?.unobserve(e);
|
|
16
|
+
}
|
|
17
|
+
unregister(e) {
|
|
18
|
+
this.cancel(this.records.get(e)), this.records.delete(e), this.observer?.unobserve(e);
|
|
19
|
+
}
|
|
20
|
+
cancel(e) {
|
|
21
|
+
const s = e?.animation;
|
|
22
|
+
s && (s.onfinish = s.oncancel = null, s.cancel(), e.animation = void 0);
|
|
23
|
+
}
|
|
24
|
+
show(e, s = !1) {
|
|
25
|
+
for (const [t, o] of this.records)
|
|
26
|
+
(t.contains(e) || s && e.contains(t)) && (this.cancel(o), o.seen = o.entered = !0, o.options.reset || this.observer?.unobserve(t));
|
|
27
|
+
}
|
|
28
|
+
refresh() {
|
|
29
|
+
const e = this.context.viewport();
|
|
30
|
+
for (const [s, t] of this.records) {
|
|
31
|
+
this.cancel(t);
|
|
32
|
+
const o = s.getBoundingClientRect();
|
|
33
|
+
o.bottom > e.top && o.top < e.bottom || !t.options.reset && o.top < e.bottom ? (t.seen = t.entered = !0, t.options.reset || this.observer?.unobserve(s)) : t.options.reset && (t.seen = !1);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
onEntries = (e) => {
|
|
37
|
+
let s = 0;
|
|
38
|
+
for (const t of e) {
|
|
39
|
+
const o = t.target, i = this.records.get(o);
|
|
40
|
+
if (!i || !o.isConnected) continue;
|
|
41
|
+
const { options: n } = i;
|
|
42
|
+
if (!t.isIntersecting) {
|
|
43
|
+
n.reset && !i.animation && (i.seen = !1);
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const c = t.rootBounds, g = c && t.boundingClientRect.height > 0 && t.boundingClientRect.width > 0 ? Math.min(1, c.height / t.boundingClientRect.height) * Math.min(1, c.width / t.boundingClientRect.width) : 1;
|
|
47
|
+
if (i.seen || t.intersectionRatio + 0.01 < Math.min(n.viewFactor, g)) continue;
|
|
48
|
+
i.seen = !0;
|
|
49
|
+
const l = i.entered;
|
|
50
|
+
i.entered = !0, n.reset || this.observer?.unobserve(o);
|
|
51
|
+
const b = this.context.viewport();
|
|
52
|
+
if (!this.context.canReveal() || !n.mobile && !this.context.finePointer.matches || t.boundingClientRect.top < b.top && !(n.reset && l) || o.contains(document.activeElement)) continue;
|
|
53
|
+
const d = Array.from(o.querySelectorAll("img"));
|
|
54
|
+
o instanceof HTMLImageElement && d.push(o);
|
|
55
|
+
let h = !0;
|
|
56
|
+
for (const r of d)
|
|
57
|
+
(!r.complete || r.naturalWidth === 0) && (h = !1, r.loading = "eager", r.decode?.().catch(() => {
|
|
58
|
+
}));
|
|
59
|
+
if (!h) continue;
|
|
60
|
+
const p = n.useDelay === "always" || n.useDelay === "once" && !l || n.useDelay === "onload" && document.readyState !== "complete" ? n.delay : 0, f = n.origin === "left" || n.origin === "top" ? `calc(-1 * ${n.distance})` : n.distance, y = n.origin === "left" || n.origin === "right" ? `translateX(${f})` : `translateY(${f})`, a = getComputedStyle(o), u = a.transform === "none" ? "" : a.transform;
|
|
61
|
+
try {
|
|
62
|
+
this.cancel(i);
|
|
63
|
+
const r = o.animate([
|
|
64
|
+
{ opacity: n.opacity, transform: `${u} ${y} scale(${n.scale === 0 ? 2e-4 : n.scale})` },
|
|
65
|
+
{ opacity: a.opacity, transform: u || "none" }
|
|
66
|
+
], {
|
|
67
|
+
duration: n.duration,
|
|
68
|
+
delay: Math.min(1e3, p + s++ * n.interval),
|
|
69
|
+
easing: n.easing,
|
|
70
|
+
fill: "backwards"
|
|
71
|
+
});
|
|
72
|
+
i.animation = r, r.onfinish = r.oncancel = () => {
|
|
73
|
+
if (i.animation === r) {
|
|
74
|
+
if (r.onfinish = r.oncancel = null, i.animation = void 0, n.reset) {
|
|
75
|
+
const m = o.getBoundingClientRect(), v = this.context.viewport();
|
|
76
|
+
(m.bottom <= v.top || m.top >= v.bottom) && (i.seen = !1);
|
|
77
|
+
}
|
|
78
|
+
n.cleanup && r.cancel();
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
} catch {
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
destroy() {
|
|
86
|
+
this.observer?.disconnect(), this.records.forEach((e) => this.cancel(e)), this.records.clear();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
export {
|
|
90
|
+
R as ScrollRevealMotion
|
|
91
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Native, serializable reveal options. Invalid values fall back to defaults. */
|
|
2
|
+
export interface ScrollRevealOptions {
|
|
3
|
+
distance?: string;
|
|
4
|
+
duration?: number;
|
|
5
|
+
delay?: number;
|
|
6
|
+
easing?: string;
|
|
7
|
+
origin?: 'top' | 'right' | 'bottom' | 'left';
|
|
8
|
+
opacity?: number;
|
|
9
|
+
scale?: number;
|
|
10
|
+
reset?: boolean;
|
|
11
|
+
viewFactor?: number;
|
|
12
|
+
mobile?: boolean;
|
|
13
|
+
cleanup?: boolean;
|
|
14
|
+
useDelay?: 'always' | 'once' | 'onload';
|
|
15
|
+
interval?: number;
|
|
16
|
+
}
|
|
17
|
+
export declare const scrollRevealDefaults: Required<ScrollRevealOptions>;
|
|
18
|
+
export declare function normalizeScrollReveal(value: unknown): Required<ScrollRevealOptions>;
|
|
19
|
+
export declare function sameScrollReveal(a: Required<ScrollRevealOptions>, b: Required<ScrollRevealOptions>): boolean;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const a = {
|
|
2
|
+
distance: "50px",
|
|
3
|
+
duration: 800,
|
|
4
|
+
delay: 200,
|
|
5
|
+
easing: "cubic-bezier(0.5, 0, 0, 1)",
|
|
6
|
+
origin: "bottom",
|
|
7
|
+
opacity: 0,
|
|
8
|
+
scale: 1,
|
|
9
|
+
reset: !1,
|
|
10
|
+
viewFactor: 0,
|
|
11
|
+
mobile: !0,
|
|
12
|
+
cleanup: !1,
|
|
13
|
+
useDelay: "always",
|
|
14
|
+
interval: 0
|
|
15
|
+
};
|
|
16
|
+
function s(i) {
|
|
17
|
+
const e = i && typeof i == "object" ? i : {}, t = { ...a };
|
|
18
|
+
for (const o of ["duration", "delay", "interval", "scale", "opacity", "viewFactor"]) {
|
|
19
|
+
const n = e[o];
|
|
20
|
+
typeof n == "number" && Number.isFinite(n) && n >= 0 && (t[o] = o === "opacity" || o === "viewFactor" ? Math.min(1, n) : n);
|
|
21
|
+
}
|
|
22
|
+
t.viewFactor = Math.round(t.viewFactor * 100) / 100;
|
|
23
|
+
for (const o of ["reset", "mobile", "cleanup"])
|
|
24
|
+
typeof e[o] == "boolean" && (t[o] = e[o]);
|
|
25
|
+
return ["top", "right", "bottom", "left"].includes(e.origin) && (t.origin = e.origin), ["always", "once", "onload"].includes(e.useDelay) && (t.useDelay = e.useDelay), typeof e.distance == "string" && typeof CSS < "u" && typeof CSS.supports == "function" && CSS.supports("transform", `translateX(${e.distance})`) && (t.distance = e.distance), typeof e.easing == "string" && typeof CSS < "u" && typeof CSS.supports == "function" && CSS.supports("animation-timing-function", e.easing) && (t.easing = e.easing), t;
|
|
26
|
+
}
|
|
27
|
+
function r(i, e) {
|
|
28
|
+
return Object.keys(a).every((t) => i[t] === e[t]);
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
s as normalizeScrollReveal,
|
|
32
|
+
r as sameScrollReveal,
|
|
33
|
+
a as scrollRevealDefaults
|
|
34
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ScrollRevealContext } from './ScrollRevealContainer';
|
|
2
|
+
/** Paging owns only registered stops and one cancellable scroll-position animation. */
|
|
3
|
+
export declare class ScrollRevealPager {
|
|
4
|
+
private sections;
|
|
5
|
+
private desktop;
|
|
6
|
+
private listeners?;
|
|
7
|
+
private movement?;
|
|
8
|
+
private lastWheel;
|
|
9
|
+
private direction;
|
|
10
|
+
private distance;
|
|
11
|
+
private consumed;
|
|
12
|
+
private readingElement?;
|
|
13
|
+
private context;
|
|
14
|
+
constructor(context: ScrollRevealContext);
|
|
15
|
+
register(element: HTMLElement): void;
|
|
16
|
+
unregister(element: HTMLElement): void;
|
|
17
|
+
private configure;
|
|
18
|
+
reset: () => void;
|
|
19
|
+
private cancel;
|
|
20
|
+
private geometry;
|
|
21
|
+
private measureSection;
|
|
22
|
+
private measure;
|
|
23
|
+
private hasPagingStops;
|
|
24
|
+
private readWheel;
|
|
25
|
+
/** Child scroll owners win, including at a contained overscroll boundary. */
|
|
26
|
+
private nestedOwns;
|
|
27
|
+
private enabled;
|
|
28
|
+
private destination;
|
|
29
|
+
private move;
|
|
30
|
+
private onWheel;
|
|
31
|
+
private onKeydown;
|
|
32
|
+
destroy(): void;
|
|
33
|
+
}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
const p = "(min-width: 1024px) and (hover: hover) and (pointer: fine)", g = [
|
|
2
|
+
"input",
|
|
3
|
+
"textarea",
|
|
4
|
+
"select",
|
|
5
|
+
"button",
|
|
6
|
+
"a[href]",
|
|
7
|
+
"summary",
|
|
8
|
+
"video",
|
|
9
|
+
"audio",
|
|
10
|
+
"iframe",
|
|
11
|
+
'[contenteditable]:not([contenteditable="false"])',
|
|
12
|
+
...[
|
|
13
|
+
"button",
|
|
14
|
+
"slider",
|
|
15
|
+
"tab",
|
|
16
|
+
"tablist",
|
|
17
|
+
"menu",
|
|
18
|
+
"menuitem",
|
|
19
|
+
"menuitemcheckbox",
|
|
20
|
+
"menuitemradio",
|
|
21
|
+
"listbox",
|
|
22
|
+
"option",
|
|
23
|
+
"textbox",
|
|
24
|
+
"combobox",
|
|
25
|
+
"spinbutton",
|
|
26
|
+
"tree",
|
|
27
|
+
"treegrid",
|
|
28
|
+
"treeitem",
|
|
29
|
+
"grid",
|
|
30
|
+
"gridcell",
|
|
31
|
+
"columnheader",
|
|
32
|
+
"rowheader",
|
|
33
|
+
"checkbox",
|
|
34
|
+
"radio",
|
|
35
|
+
"radiogroup",
|
|
36
|
+
"switch",
|
|
37
|
+
"link",
|
|
38
|
+
"searchbox",
|
|
39
|
+
"scrollbar",
|
|
40
|
+
"application"
|
|
41
|
+
].map((f) => `[role~="${f}"]`)
|
|
42
|
+
].join(", "), o = 2, x = 12, b = 220;
|
|
43
|
+
class w {
|
|
44
|
+
sections = /* @__PURE__ */ new Set();
|
|
45
|
+
desktop = window.matchMedia(p);
|
|
46
|
+
listeners;
|
|
47
|
+
movement;
|
|
48
|
+
lastWheel = -1 / 0;
|
|
49
|
+
direction = 0;
|
|
50
|
+
distance = 0;
|
|
51
|
+
consumed = !1;
|
|
52
|
+
readingElement;
|
|
53
|
+
context;
|
|
54
|
+
constructor(t) {
|
|
55
|
+
this.context = t, this.desktop.addEventListener("change", this.configure);
|
|
56
|
+
}
|
|
57
|
+
register(t) {
|
|
58
|
+
this.sections.add(t), this.configure();
|
|
59
|
+
}
|
|
60
|
+
unregister(t) {
|
|
61
|
+
this.sections.delete(t), this.configure();
|
|
62
|
+
}
|
|
63
|
+
configure = () => {
|
|
64
|
+
this.reset();
|
|
65
|
+
const t = this.sections.size >= 2 && this.desktop.matches;
|
|
66
|
+
if (!!this.listeners === t || (this.listeners?.abort(), this.listeners = void 0, !t)) return;
|
|
67
|
+
this.listeners = new AbortController();
|
|
68
|
+
const e = this.context.documentRoot ? window : this.context.container, i = { capture: !0, signal: this.listeners.signal };
|
|
69
|
+
e.addEventListener("wheel", this.onWheel, { ...i, passive: !1 }), e.addEventListener("keydown", this.onKeydown, i);
|
|
70
|
+
};
|
|
71
|
+
reset = () => {
|
|
72
|
+
this.cancel(), this.lastWheel = -1 / 0, this.direction = this.distance = 0, this.consumed = !1, this.readingElement = void 0;
|
|
73
|
+
};
|
|
74
|
+
cancel() {
|
|
75
|
+
this.movement && (cancelAnimationFrame(this.movement.frame), this.movement = void 0);
|
|
76
|
+
}
|
|
77
|
+
geometry() {
|
|
78
|
+
const t = this.context.viewport();
|
|
79
|
+
return {
|
|
80
|
+
from: this.context.position(),
|
|
81
|
+
top: t.top,
|
|
82
|
+
bottom: t.bottom,
|
|
83
|
+
padding: this.context.padding(),
|
|
84
|
+
limit: this.context.limit()
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
measureSection(t, e = this.geometry()) {
|
|
88
|
+
if (!t.isConnected) return;
|
|
89
|
+
const i = t.getBoundingClientRect();
|
|
90
|
+
if (!i.height || !i.width) return;
|
|
91
|
+
const n = (a) => Math.max(0, Math.min(a, e.limit)), s = n(i.top - e.top + e.from - e.padding);
|
|
92
|
+
return { element: t, start: s, end: n(Math.max(s, i.bottom - e.bottom + e.from)) };
|
|
93
|
+
}
|
|
94
|
+
measure() {
|
|
95
|
+
const t = this.geometry();
|
|
96
|
+
return Array.from(this.sections).map((e) => this.measureSection(e, t)).filter((e) => !!e).sort((e, i) => e.start - i.start);
|
|
97
|
+
}
|
|
98
|
+
hasPagingStops() {
|
|
99
|
+
const t = this.geometry();
|
|
100
|
+
let e = 0;
|
|
101
|
+
for (const i of this.sections)
|
|
102
|
+
if (this.measureSection(i, t) && ++e === 2) return !0;
|
|
103
|
+
return !1;
|
|
104
|
+
}
|
|
105
|
+
readWheel(t, e, i, n, s = !1) {
|
|
106
|
+
const a = this.context.position();
|
|
107
|
+
if (a < t.start - o || a > t.end + o || (e > 0 ? a >= t.end - o : a <= t.start + o)) return !1;
|
|
108
|
+
this.readingElement = t.element, this.consumed = !1, this.direction = e, this.distance = 0;
|
|
109
|
+
const r = a + i, d = r >= t.end || r <= t.start;
|
|
110
|
+
return (d || s) && (n.preventDefault(), this.context.write(Math.max(t.start, Math.min(r, t.end))), this.consumed = d), !0;
|
|
111
|
+
}
|
|
112
|
+
/** Child scroll owners win, including at a contained overscroll boundary. */
|
|
113
|
+
nestedOwns(t, e) {
|
|
114
|
+
for (const i of t.composedPath()) {
|
|
115
|
+
if (i === this.context.container || i === document.body || i === document.documentElement) break;
|
|
116
|
+
if (!(i instanceof HTMLElement)) continue;
|
|
117
|
+
const n = getComputedStyle(i);
|
|
118
|
+
if (!/^(auto|scroll|overlay)$/.test(n.overflowY)) continue;
|
|
119
|
+
const s = e > 0 ? i.scrollTop + i.clientHeight < i.scrollHeight - 1 : i.scrollTop > 0;
|
|
120
|
+
if (i.scrollHeight > i.clientHeight && s || /^(contain|none)$/.test(n.overscrollBehaviorY)) return !0;
|
|
121
|
+
}
|
|
122
|
+
return !1;
|
|
123
|
+
}
|
|
124
|
+
enabled() {
|
|
125
|
+
if (document.hidden || !this.desktop.matches) return !1;
|
|
126
|
+
const { container: t, documentRoot: e } = this.context;
|
|
127
|
+
return ![t, ...e ? [document.body] : []].some((i) => /^(hidden|clip)$/.test(getComputedStyle(i).overflowY));
|
|
128
|
+
}
|
|
129
|
+
destination(t, e, i) {
|
|
130
|
+
const n = this.context.position();
|
|
131
|
+
let s, a, r;
|
|
132
|
+
for (const m of i)
|
|
133
|
+
if (m.start <= n + o && (s = m), m.start < n - o && (a = m), m.start > n + o) {
|
|
134
|
+
r = m;
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
const d = s && s.end > s.start + o && n <= s.end + o, c = this.context.viewport(), l = Math.max(48, c.bottom - c.top - this.context.padding() - 48);
|
|
138
|
+
let u, h;
|
|
139
|
+
if (e && d && (t > 0 ? n < s.end - o : n > s.start + o) ? (h = s, u = Math.min(s.end, Math.max(s.start, n + t * l))) : (h = t > 0 ? r : a, u = h?.start ?? (t > 0 ? this.context.limit() : 0)), !(Math.abs(u - n) <= o))
|
|
140
|
+
return {
|
|
141
|
+
position: u,
|
|
142
|
+
element: h?.element,
|
|
143
|
+
progress: h && h.end > h.start ? (u - h.start) / (h.end - h.start) : 0,
|
|
144
|
+
atEnd: !h && t > 0
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
move(t, e) {
|
|
148
|
+
this.cancel(), this.readingElement = void 0;
|
|
149
|
+
const i = this.context.position(), n = { frame: 0, direction: e };
|
|
150
|
+
this.movement = n;
|
|
151
|
+
const s = () => {
|
|
152
|
+
if (this.movement !== n) return;
|
|
153
|
+
const c = t.element && this.sections.has(t.element) ? this.measureSection(t.element) : void 0, l = c ? c.start + (c.end - c.start) * t.progress : t.atEnd ? this.context.limit() : Math.min(t.position, this.context.limit());
|
|
154
|
+
(!t.element || c) && Math.abs(l - this.context.position()) > o && this.context.write(l), this.movement = void 0;
|
|
155
|
+
};
|
|
156
|
+
if (this.context.reducedMotion.matches) {
|
|
157
|
+
this.context.write(t.position), s();
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
const a = window.location.href, r = performance.now(), d = (c) => {
|
|
161
|
+
if (this.movement !== n) return;
|
|
162
|
+
if (document.hidden || window.location.href !== a || t.element && !t.element.isConnected) {
|
|
163
|
+
this.reset();
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
const l = Math.min(1, (c - r) / 850);
|
|
167
|
+
this.context.write(i + (t.position - i) * (1 - (1 - l) ** 3)), l < 1 ? n.frame = requestAnimationFrame(d) : s();
|
|
168
|
+
};
|
|
169
|
+
n.frame = requestAnimationFrame(d);
|
|
170
|
+
}
|
|
171
|
+
onWheel = (t) => {
|
|
172
|
+
if (this.context.syncNavigation(), !this.enabled() || !t.cancelable || t.defaultPrevented || t.ctrlKey || t.metaKey || t.altKey || t.shiftKey || !Number.isFinite(t.deltaY) || !Number.isFinite(t.deltaX) || !t.deltaY || Math.abs(t.deltaX) > Math.abs(t.deltaY)) {
|
|
173
|
+
this.movement && this.reset();
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
const e = Math.sign(t.deltaY), i = performance.now();
|
|
177
|
+
if (i - this.lastWheel >= b && (this.distance = 0, this.consumed = !1), this.lastWheel = i, this.nestedOwns(t, e)) {
|
|
178
|
+
this.cancel(), this.consumed = !0, this.direction = e, this.distance = 0;
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
if (!this.hasPagingStops()) {
|
|
182
|
+
this.reset();
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
const n = t.deltaMode === 1 ? 16 : t.deltaMode === 2 ? this.context.viewport().bottom - this.context.viewport().top - this.context.padding() : 1;
|
|
186
|
+
if (this.consumed && e === this.direction) {
|
|
187
|
+
t.preventDefault();
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
if (this.movement?.direction === e) {
|
|
191
|
+
t.preventDefault(), this.consumed = !0, this.direction = e, this.distance = 0;
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
if (!this.movement && this.readingElement) {
|
|
195
|
+
const r = this.measureSection(this.readingElement);
|
|
196
|
+
if (r && this.readWheel(r, e, t.deltaY * n, t)) return;
|
|
197
|
+
this.readingElement = void 0;
|
|
198
|
+
}
|
|
199
|
+
if (Math.sign(this.distance) !== e && (this.distance = 0), this.distance += t.deltaY * n, Math.abs(this.distance) < x) {
|
|
200
|
+
t.preventDefault();
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
const s = this.measure();
|
|
204
|
+
if (s.length < 2) return;
|
|
205
|
+
if (!this.movement) {
|
|
206
|
+
const r = this.context.position(), d = s.find((c) => r >= c.start - o && r <= c.end + o && (e > 0 ? r < c.end - o : r > c.start + o));
|
|
207
|
+
if (d && this.readWheel(d, e, this.distance, t, this.distance !== t.deltaY * n)) return;
|
|
208
|
+
}
|
|
209
|
+
const a = this.destination(e, !1, s);
|
|
210
|
+
if (!a) {
|
|
211
|
+
this.distance = 0;
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
t.preventDefault(), this.direction = e, this.distance = 0, this.consumed = !0, this.move(a, e);
|
|
215
|
+
};
|
|
216
|
+
onKeydown = (t) => {
|
|
217
|
+
if (this.context.syncNavigation(), !this.enabled() || t.defaultPrevented || t.ctrlKey || t.metaKey || t.altKey) return;
|
|
218
|
+
const e = t.key === "PageDown" || t.key === " " && !t.shiftKey ? 1 : t.key === "PageUp" || t.key === " " && t.shiftKey ? -1 : 0;
|
|
219
|
+
if (!e) {
|
|
220
|
+
["ArrowUp", "ArrowDown", "Home", "End", "Tab", "Escape"].includes(t.key) && this.reset();
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
for (const s of t.composedPath()) {
|
|
224
|
+
if (s === this.context.container) break;
|
|
225
|
+
if (s instanceof Element && (s.matches(g) || s.hasAttribute("tabindex") && Number(s.getAttribute("tabindex")) >= 0)) return;
|
|
226
|
+
}
|
|
227
|
+
if (this.nestedOwns(t, e)) return;
|
|
228
|
+
const i = this.measure();
|
|
229
|
+
if (i.length < 2) return;
|
|
230
|
+
const n = this.destination(e, !0, i);
|
|
231
|
+
n && (t.preventDefault(), !(t.repeat || this.movement?.direction === e) && (this.reset(), this.move(n, e)));
|
|
232
|
+
};
|
|
233
|
+
destroy() {
|
|
234
|
+
this.reset(), this.listeners?.abort(), this.desktop.removeEventListener("change", this.configure), this.sections.clear();
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
export {
|
|
238
|
+
w as ScrollRevealPager
|
|
239
|
+
};
|