fetta 1.5.2 → 1.5.3
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/chunk-PA22PLRB.js +73 -0
- package/dist/motion.js +8 -35
- package/dist/react.js +8 -35
- package/package.json +1 -1
- package/dist/chunk-V7FJXNWJ.js +0 -43
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// src/internal/initialStyles.ts
|
|
2
|
+
function reapplyInitialStyles(elements, style) {
|
|
3
|
+
if (!style || elements.length === 0) return;
|
|
4
|
+
const isFn = typeof style === "function";
|
|
5
|
+
for (let i = 0; i < elements.length; i++) {
|
|
6
|
+
const el = elements[i];
|
|
7
|
+
const styles = isFn ? style(el, i) : style;
|
|
8
|
+
for (const [key, value] of Object.entries(styles)) {
|
|
9
|
+
if (value == null) continue;
|
|
10
|
+
if (key === "cssText") {
|
|
11
|
+
if (typeof value === "string") {
|
|
12
|
+
el.style.cssText = value;
|
|
13
|
+
}
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
if (typeof value !== "string" && typeof value !== "number") continue;
|
|
17
|
+
const cssValue = typeof value === "number" ? String(value) : value;
|
|
18
|
+
const cssKey = key.startsWith("--") ? key : key.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
|
|
19
|
+
el.style.setProperty(cssKey, cssValue);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function reapplyInitialClasses(elements, className) {
|
|
24
|
+
if (!className || elements.length === 0) return;
|
|
25
|
+
const classes = className.split(/\s+/).filter(Boolean);
|
|
26
|
+
for (const el of elements) {
|
|
27
|
+
el.classList.add(...classes);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// src/internal/waitForFontsReady.ts
|
|
32
|
+
async function waitForFontsReady(waitForFonts) {
|
|
33
|
+
if (!waitForFonts) return;
|
|
34
|
+
const fonts = document.fonts;
|
|
35
|
+
const ready = fonts?.ready;
|
|
36
|
+
if (!ready || typeof ready.then !== "function") return;
|
|
37
|
+
try {
|
|
38
|
+
await ready;
|
|
39
|
+
} catch {
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// src/internal/viewportObserver.ts
|
|
44
|
+
function createViewportObserver(options, hasTriggeredOnceRef, onEnter, onLeave) {
|
|
45
|
+
const vpOptions = options ?? {};
|
|
46
|
+
const threshold = vpOptions.amount === "some" ? 0 : vpOptions.amount === "all" ? 1 : vpOptions.amount ?? 0;
|
|
47
|
+
const leaveThreshold = vpOptions.leave === "some" ? 0 : vpOptions.leave === "all" ? 1 : vpOptions.leave ?? 0;
|
|
48
|
+
const rootMargin = vpOptions.margin ?? "0px";
|
|
49
|
+
const root = vpOptions.root?.current ?? void 0;
|
|
50
|
+
const isOnce = vpOptions.once === true;
|
|
51
|
+
const thresholdValues = Array.from(/* @__PURE__ */ new Set([0, threshold, leaveThreshold])).sort(
|
|
52
|
+
(a, b) => a - b
|
|
53
|
+
);
|
|
54
|
+
const thresholds = thresholdValues.length === 1 ? thresholdValues[0] : thresholdValues;
|
|
55
|
+
return new IntersectionObserver(
|
|
56
|
+
(entries) => {
|
|
57
|
+
const entry = entries[0];
|
|
58
|
+
if (!entry) return;
|
|
59
|
+
if (entry.isIntersecting && entry.intersectionRatio >= threshold) {
|
|
60
|
+
if (isOnce && hasTriggeredOnceRef.current) return;
|
|
61
|
+
hasTriggeredOnceRef.current = true;
|
|
62
|
+
onEnter();
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (isOnce) return;
|
|
66
|
+
const shouldLeave = leaveThreshold === 0 ? !entry.isIntersecting : entry.intersectionRatio <= leaveThreshold;
|
|
67
|
+
if (shouldLeave) onLeave();
|
|
68
|
+
},
|
|
69
|
+
{ threshold: thresholds, rootMargin, root }
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export { createViewportObserver, reapplyInitialClasses, reapplyInitialStyles, waitForFontsReady };
|
package/dist/motion.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { waitForFontsReady, reapplyInitialStyles, reapplyInitialClasses } from './chunk-
|
|
1
|
+
import { waitForFontsReady, createViewportObserver, reapplyInitialStyles, reapplyInitialClasses } from './chunk-PA22PLRB.js';
|
|
2
2
|
import { splitTextData, buildLineFingerprintFromData, normalizeToPromise, buildKerningStyleKey, resolveAutoSplitTargets, getObservedWidth, recordWidthChange, resolveAutoSplitWidth, querySplitWords, clearKerningCompensation, applyKerningCompensation } from './chunk-OUXSJF3P.js';
|
|
3
3
|
import { scroll, animate } from 'motion';
|
|
4
4
|
import { usePresence, useReducedMotion, MotionConfig, motion } from 'motion/react';
|
|
@@ -1035,39 +1035,6 @@ var SplitText = forwardRef(function SplitText2({
|
|
|
1035
1035
|
pendingSignatureRef.current = null;
|
|
1036
1036
|
resetSplitState(next);
|
|
1037
1037
|
}, [isPresent, resetSplitState]);
|
|
1038
|
-
function setupViewportObserver(container) {
|
|
1039
|
-
const vpOptions = viewportRef.current || {};
|
|
1040
|
-
const amount = vpOptions.amount ?? 0;
|
|
1041
|
-
const leave = vpOptions.leave ?? 0;
|
|
1042
|
-
const threshold = amount === "some" ? 0 : amount === "all" ? 1 : amount;
|
|
1043
|
-
const leaveThreshold = leave === "some" ? 0 : leave === "all" ? 1 : leave;
|
|
1044
|
-
const rootMargin = vpOptions.margin ?? "0px";
|
|
1045
|
-
const root = vpOptions.root?.current ?? void 0;
|
|
1046
|
-
const thresholdValues = Array.from(
|
|
1047
|
-
/* @__PURE__ */ new Set([0, threshold, leaveThreshold])
|
|
1048
|
-
).sort((a, b) => a - b);
|
|
1049
|
-
const thresholds = thresholdValues.length === 1 ? thresholdValues[0] : thresholdValues;
|
|
1050
|
-
observerRef.current = new IntersectionObserver(
|
|
1051
|
-
(entries) => {
|
|
1052
|
-
const entry = entries[0];
|
|
1053
|
-
if (!entry) return;
|
|
1054
|
-
const isOnce = vpOptions.once;
|
|
1055
|
-
if (entry.isIntersecting && entry.intersectionRatio >= threshold) {
|
|
1056
|
-
if (isOnce && hasTriggeredOnceRef.current) return;
|
|
1057
|
-
hasTriggeredOnceRef.current = true;
|
|
1058
|
-
setIsInView(true);
|
|
1059
|
-
return;
|
|
1060
|
-
}
|
|
1061
|
-
if (isOnce) return;
|
|
1062
|
-
const shouldLeave = leaveThreshold === 0 ? !entry.isIntersecting : entry.intersectionRatio <= leaveThreshold;
|
|
1063
|
-
if (shouldLeave) {
|
|
1064
|
-
setIsInView(false);
|
|
1065
|
-
}
|
|
1066
|
-
},
|
|
1067
|
-
{ threshold: thresholds, rootMargin, root }
|
|
1068
|
-
);
|
|
1069
|
-
observerRef.current.observe(container);
|
|
1070
|
-
}
|
|
1071
1038
|
const buildSplitDataFromProbe = useCallback((width) => {
|
|
1072
1039
|
const currentChild = childElement && childElement.isConnected ? childElement : (() => {
|
|
1073
1040
|
const element = containerRef.current?.firstElementChild;
|
|
@@ -1657,7 +1624,13 @@ var SplitText = forwardRef(function SplitText2({
|
|
|
1657
1624
|
observerRef.current.disconnect();
|
|
1658
1625
|
observerRef.current = null;
|
|
1659
1626
|
}
|
|
1660
|
-
|
|
1627
|
+
observerRef.current = createViewportObserver(
|
|
1628
|
+
viewportRef.current,
|
|
1629
|
+
hasTriggeredOnceRef,
|
|
1630
|
+
() => setIsInView(true),
|
|
1631
|
+
() => setIsInView(false)
|
|
1632
|
+
);
|
|
1633
|
+
observerRef.current.observe(containerRef.current);
|
|
1661
1634
|
return () => {
|
|
1662
1635
|
if (observerRef.current) {
|
|
1663
1636
|
observerRef.current.disconnect();
|
package/dist/react.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { waitForFontsReady, reapplyInitialStyles, reapplyInitialClasses } from './chunk-
|
|
1
|
+
import { waitForFontsReady, createViewportObserver, reapplyInitialStyles, reapplyInitialClasses } from './chunk-PA22PLRB.js';
|
|
2
2
|
import { splitText, normalizeToPromise } from './chunk-OUXSJF3P.js';
|
|
3
3
|
import { forwardRef, useRef, useCallback, useState, useLayoutEffect, useEffect, isValidElement, createElement } from 'react';
|
|
4
4
|
|
|
@@ -136,42 +136,15 @@ var SplitText = forwardRef(
|
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
if (needsViewport && containerRef.current) {
|
|
139
|
-
|
|
139
|
+
observerRef.current = createViewportObserver(
|
|
140
|
+
viewportRef.current,
|
|
141
|
+
hasTriggeredOnceRef,
|
|
142
|
+
() => setIsInView(true),
|
|
143
|
+
() => setIsInView(false)
|
|
144
|
+
);
|
|
145
|
+
observerRef.current.observe(containerRef.current);
|
|
140
146
|
}
|
|
141
147
|
});
|
|
142
|
-
function setupViewportObserver(container) {
|
|
143
|
-
const vpOptions = viewportRef.current || {};
|
|
144
|
-
const amount = vpOptions.amount ?? 0;
|
|
145
|
-
const leave = vpOptions.leave ?? 0;
|
|
146
|
-
const threshold = amount === "some" ? 0 : amount === "all" ? 1 : amount;
|
|
147
|
-
const leaveThreshold = leave === "some" ? 0 : leave === "all" ? 1 : leave;
|
|
148
|
-
const rootMargin = vpOptions.margin ?? "0px";
|
|
149
|
-
const root = vpOptions.root?.current ?? void 0;
|
|
150
|
-
const thresholdValues = Array.from(
|
|
151
|
-
/* @__PURE__ */ new Set([0, threshold, leaveThreshold])
|
|
152
|
-
).sort((a, b) => a - b);
|
|
153
|
-
const thresholds = thresholdValues.length === 1 ? thresholdValues[0] : thresholdValues;
|
|
154
|
-
observerRef.current = new IntersectionObserver(
|
|
155
|
-
(entries) => {
|
|
156
|
-
const entry = entries[0];
|
|
157
|
-
if (!entry) return;
|
|
158
|
-
const isOnce = vpOptions.once;
|
|
159
|
-
if (entry.isIntersecting && entry.intersectionRatio >= threshold) {
|
|
160
|
-
if (isOnce && hasTriggeredOnceRef.current) return;
|
|
161
|
-
hasTriggeredOnceRef.current = true;
|
|
162
|
-
setIsInView(true);
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
if (isOnce) return;
|
|
166
|
-
const shouldLeave = leaveThreshold === 0 ? !entry.isIntersecting : entry.intersectionRatio <= leaveThreshold;
|
|
167
|
-
if (shouldLeave) {
|
|
168
|
-
setIsInView(false);
|
|
169
|
-
}
|
|
170
|
-
},
|
|
171
|
-
{ threshold: thresholds, rootMargin, root }
|
|
172
|
-
);
|
|
173
|
-
observerRef.current.observe(container);
|
|
174
|
-
}
|
|
175
148
|
return () => {
|
|
176
149
|
isMounted = false;
|
|
177
150
|
if (observerRef.current) {
|
package/package.json
CHANGED
package/dist/chunk-V7FJXNWJ.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// src/internal/initialStyles.ts
|
|
2
|
-
function reapplyInitialStyles(elements, style) {
|
|
3
|
-
if (!style || elements.length === 0) return;
|
|
4
|
-
const isFn = typeof style === "function";
|
|
5
|
-
for (let i = 0; i < elements.length; i++) {
|
|
6
|
-
const el = elements[i];
|
|
7
|
-
const styles = isFn ? style(el, i) : style;
|
|
8
|
-
for (const [key, value] of Object.entries(styles)) {
|
|
9
|
-
if (value == null) continue;
|
|
10
|
-
if (key === "cssText") {
|
|
11
|
-
if (typeof value === "string") {
|
|
12
|
-
el.style.cssText = value;
|
|
13
|
-
}
|
|
14
|
-
continue;
|
|
15
|
-
}
|
|
16
|
-
if (typeof value !== "string" && typeof value !== "number") continue;
|
|
17
|
-
const cssValue = typeof value === "number" ? String(value) : value;
|
|
18
|
-
const cssKey = key.startsWith("--") ? key : key.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
|
|
19
|
-
el.style.setProperty(cssKey, cssValue);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
function reapplyInitialClasses(elements, className) {
|
|
24
|
-
if (!className || elements.length === 0) return;
|
|
25
|
-
const classes = className.split(/\s+/).filter(Boolean);
|
|
26
|
-
for (const el of elements) {
|
|
27
|
-
el.classList.add(...classes);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// src/internal/waitForFontsReady.ts
|
|
32
|
-
async function waitForFontsReady(waitForFonts) {
|
|
33
|
-
if (!waitForFonts) return;
|
|
34
|
-
const fonts = document.fonts;
|
|
35
|
-
const ready = fonts?.ready;
|
|
36
|
-
if (!ready || typeof ready.then !== "function") return;
|
|
37
|
-
try {
|
|
38
|
-
await ready;
|
|
39
|
-
} catch {
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export { reapplyInitialClasses, reapplyInitialStyles, waitForFontsReady };
|