@cosmictraveler002/anim-kit 1.1.0 → 1.3.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/README.md +293 -36
- package/dist/anim-kit.standalone.js +18 -8
- package/dist/anim-kit.standalone.js.map +1 -1
- package/dist/core/gsap.d.ts +3 -2
- package/dist/core/gsap.d.ts.map +1 -1
- package/dist/core/gsap.js +4 -3
- package/dist/core/gsap.js.map +1 -1
- package/dist/core/smooth-scroll.d.ts +1 -1
- package/dist/core/smooth-scroll.js +1 -1
- package/dist/effects/clip-wipe.d.ts +10 -2
- package/dist/effects/clip-wipe.d.ts.map +1 -1
- package/dist/effects/clip-wipe.js +30 -9
- package/dist/effects/clip-wipe.js.map +1 -1
- package/dist/effects/cursor-follower.d.ts.map +1 -1
- package/dist/effects/cursor-follower.js +22 -4
- package/dist/effects/cursor-follower.js.map +1 -1
- package/dist/effects/drag-rail.d.ts +23 -0
- package/dist/effects/drag-rail.d.ts.map +1 -0
- package/dist/effects/drag-rail.js +196 -0
- package/dist/effects/drag-rail.js.map +1 -0
- package/dist/effects/flip-words.d.ts +31 -0
- package/dist/effects/flip-words.d.ts.map +1 -0
- package/dist/effects/flip-words.js +104 -0
- package/dist/effects/flip-words.js.map +1 -0
- package/dist/effects/magnetic.d.ts +15 -0
- package/dist/effects/magnetic.d.ts.map +1 -0
- package/dist/effects/magnetic.js +59 -0
- package/dist/effects/magnetic.js.map +1 -0
- package/dist/effects/media-settle.d.ts +2 -0
- package/dist/effects/media-settle.d.ts.map +1 -1
- package/dist/effects/media-settle.js +5 -2
- package/dist/effects/media-settle.js.map +1 -1
- package/dist/effects/preloader.js +1 -1
- package/dist/effects/reel-text.d.ts +19 -0
- package/dist/effects/reel-text.d.ts.map +1 -0
- package/dist/effects/reel-text.js +163 -0
- package/dist/effects/reel-text.js.map +1 -0
- package/dist/index.d.ts +14 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/three/index.d.ts +13 -0
- package/dist/three/index.d.ts.map +1 -0
- package/dist/three/index.js +12 -0
- package/dist/three/index.js.map +1 -0
- package/dist/three/webgl-media.d.ts +21 -0
- package/dist/three/webgl-media.d.ts.map +1 -0
- package/dist/three/webgl-media.js +268 -0
- package/dist/three/webgl-media.js.map +1 -0
- package/package.json +17 -1
- package/src/core/gsap.ts +4 -3
- package/src/core/smooth-scroll.ts +1 -1
- package/src/effects/clip-wipe.ts +50 -10
- package/src/effects/cursor-follower.ts +21 -4
- package/src/effects/drag-rail.ts +236 -0
- package/src/effects/flip-words.ts +148 -0
- package/src/effects/magnetic.ts +87 -0
- package/src/effects/media-settle.ts +7 -1
- package/src/effects/preloader.ts +1 -1
- package/src/effects/reel-text.ts +212 -0
- package/src/index.ts +18 -2
- package/src/three/index.ts +12 -0
- package/src/three/webgl-media.ts +325 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flip word transfer — words glide from one layout into another (FLIP).
|
|
3
|
+
*
|
|
4
|
+
* The source block holds the words; `to` is the block they land in. Both
|
|
5
|
+
* blocks should share one grid cell so the page never reflows when the
|
|
6
|
+
* words move:
|
|
7
|
+
*
|
|
8
|
+
* .flip-stage { display: grid; }
|
|
9
|
+
* .flip-stage > div { grid-area: 1 / 1; } // source + destination overlap
|
|
10
|
+
*
|
|
11
|
+
* On trigger every word is measured where it stands, moved into the
|
|
12
|
+
* destination, and animated from its old position (the classic FLIP
|
|
13
|
+
* technique), with a mid-flight squash so the words pop as they travel.
|
|
14
|
+
* Because the measurement happens up front, the words *look* like they are
|
|
15
|
+
* still in the source at scroll progress 0 even though they already live in
|
|
16
|
+
* the destination — so a scrubbed transfer reverses perfectly.
|
|
17
|
+
*
|
|
18
|
+
* flipWords("[data-flip-from]", { to: "[data-flip-to]", scrub: 1 });
|
|
19
|
+
*
|
|
20
|
+
* destroy() kills the timeline, puts every word back in its original
|
|
21
|
+
* parent (in the original order) and restores its inline transform.
|
|
22
|
+
*/
|
|
23
|
+
import { gsap, Flip, ScrollTrigger, initGSAP, killTweens } from "../core/gsap.js";
|
|
24
|
+
import { guard } from "../core/guard.js";
|
|
25
|
+
import { one, toArray } from "../core/util.js";
|
|
26
|
+
export function flipWords(from, options) {
|
|
27
|
+
initGSAP();
|
|
28
|
+
const src = one(from);
|
|
29
|
+
const dest = one(options?.to);
|
|
30
|
+
if (!src || !dest)
|
|
31
|
+
return () => { };
|
|
32
|
+
const { words, duration = 1.4, ease = "power4.inOut", stagger = 0.2, scale = 0.2, mode = "scroll", scrub, start = "top 75%", end = "bottom 45%", } = options;
|
|
33
|
+
const marked = toArray(src.querySelectorAll("[data-flip-word]"));
|
|
34
|
+
const wordEls = words
|
|
35
|
+
? toArray(words, src)
|
|
36
|
+
: marked.length
|
|
37
|
+
? marked
|
|
38
|
+
: [...src.children];
|
|
39
|
+
if (!wordEls.length)
|
|
40
|
+
return () => { };
|
|
41
|
+
return guard(options, () => {
|
|
42
|
+
// Remember each word's home so destroy() can put everything back in order.
|
|
43
|
+
const home = wordEls.map((w) => ({ parent: w.parentNode, next: w.nextSibling }));
|
|
44
|
+
const prevTransform = wordEls.map((w) => w.style.transform);
|
|
45
|
+
// Measure in the source, move into the destination, then animate from
|
|
46
|
+
// the measurement — the FLIP. The wrapper timeline owns the flight so
|
|
47
|
+
// ScrollTrigger can scrub it and the scale accents can share its clock.
|
|
48
|
+
const state = Flip.getState(wordEls);
|
|
49
|
+
wordEls.forEach((w) => dest.appendChild(w));
|
|
50
|
+
const tl = gsap.timeline({ paused: true });
|
|
51
|
+
// The wrapper is paused, and `add` is synchronous, so the Flip child
|
|
52
|
+
// never renders on the global timeline before the wrapper owns it.
|
|
53
|
+
tl.add(Flip.from(state, { duration, ease, stagger: { each: stagger } }), 0);
|
|
54
|
+
if (scale > 0) {
|
|
55
|
+
wordEls.forEach((w, i) => {
|
|
56
|
+
const at = i * stagger;
|
|
57
|
+
tl.to(w, { scale, duration: duration * 0.5, ease }, at);
|
|
58
|
+
tl.to(w, { scale: 1, duration: duration * 0.5, ease }, at + duration * 0.5);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
let st;
|
|
62
|
+
if (mode === "immediate") {
|
|
63
|
+
tl.play(0);
|
|
64
|
+
}
|
|
65
|
+
else if (scrub !== undefined) {
|
|
66
|
+
st = ScrollTrigger.create({
|
|
67
|
+
trigger: src,
|
|
68
|
+
start,
|
|
69
|
+
end,
|
|
70
|
+
scrub: scrub === true ? true : scrub,
|
|
71
|
+
animation: tl,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
st = ScrollTrigger.create({
|
|
76
|
+
trigger: src,
|
|
77
|
+
start,
|
|
78
|
+
animation: tl,
|
|
79
|
+
toggleActions: "play none none reverse",
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
ScrollTrigger.refresh();
|
|
83
|
+
return () => {
|
|
84
|
+
st?.kill();
|
|
85
|
+
tl.kill();
|
|
86
|
+
killTweens(wordEls);
|
|
87
|
+
// Reparent home. A stored `next` sibling that has moved with the words
|
|
88
|
+
// is not in the parent anymore — fall back to appending in order.
|
|
89
|
+
wordEls.forEach((w, i) => {
|
|
90
|
+
const h = home[i];
|
|
91
|
+
if (!h.parent)
|
|
92
|
+
return;
|
|
93
|
+
const ref = h.next && h.next.parentNode === h.parent ? h.next : null;
|
|
94
|
+
h.parent.insertBefore(w, ref);
|
|
95
|
+
});
|
|
96
|
+
gsap.set(wordEls, { clearProps: "transform" });
|
|
97
|
+
wordEls.forEach((w, i) => {
|
|
98
|
+
w.style.transform = prevTransform[i];
|
|
99
|
+
});
|
|
100
|
+
ScrollTrigger.refresh();
|
|
101
|
+
};
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=flip-words.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flip-words.js","sourceRoot":"","sources":["../../src/effects/flip-words.ts"],"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AAC,CAAC;YAChC,CAAC,CAAC,CAAC;YACH,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC,CAAC;YAC/C,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;gBACvB,CAAC,CAAC,KAAK,CAAC,SAAS,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;YACvC,CAAC,CAAC,CAAC;YACH,aAAa,CAAC,OAAO,EAAE,CAAC;QAC1B,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CommonOptions, Destroy, TargetLike } from "../core/types.js";
|
|
2
|
+
export interface MagneticOptions extends CommonOptions {
|
|
3
|
+
/** How far the element follows the pointer — fraction of its own box. @default 0.4 */
|
|
4
|
+
strength?: number;
|
|
5
|
+
/** Max tilt in degrees at full pull (0 disables rotation). @default 8 */
|
|
6
|
+
rotation?: number;
|
|
7
|
+
/** Scale held while the pointer is over the element (1 = none). @default 1 */
|
|
8
|
+
scale?: number;
|
|
9
|
+
/** Spring-back duration, seconds. @default 1.2 */
|
|
10
|
+
duration?: number;
|
|
11
|
+
/** Spring-back ease. @default "elastic.out(1, 0.35)" */
|
|
12
|
+
ease?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function magnetic(target: TargetLike, options?: MagneticOptions): Destroy;
|
|
15
|
+
//# sourceMappingURL=magnetic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"magnetic.d.ts","sourceRoot":"","sources":["../../src/effects/magnetic.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE3E,MAAM,WAAW,eAAgB,SAAQ,aAAa;IACpD,sFAAsF;IACtF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yEAAyE;IACzE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,8EAA8E;IAC9E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kDAAkD;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,wDAAwD;IACxD,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,GAAE,eAAoB,GAAG,OAAO,CAuDnF"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Magnetic hover — buttons and links that pull toward the pointer.
|
|
3
|
+
*
|
|
4
|
+
* While the pointer is over the element it follows the cursor (a fraction
|
|
5
|
+
* of its own box), tilts toward the pull, and optionally grows a touch.
|
|
6
|
+
* On leave it springs back to rest with an elastic snap:
|
|
7
|
+
*
|
|
8
|
+
* magnetic("[data-magnet]", { strength: 0.5, rotation: 10 });
|
|
9
|
+
*
|
|
10
|
+
* Attach it to individual buttons/links (or a container's children — pass
|
|
11
|
+
* the list). destroy() removes the listeners, kills in-flight tweens and
|
|
12
|
+
* restores the inline transform.
|
|
13
|
+
*/
|
|
14
|
+
import { gsap, initGSAP, killTweens } from "../core/gsap.js";
|
|
15
|
+
import { guard } from "../core/guard.js";
|
|
16
|
+
import { toArray } from "../core/util.js";
|
|
17
|
+
export function magnetic(target, options = {}) {
|
|
18
|
+
initGSAP();
|
|
19
|
+
const els = toArray(target);
|
|
20
|
+
if (!els.length)
|
|
21
|
+
return () => { };
|
|
22
|
+
const { strength = 0.4, rotation = 8, scale = 1, duration = 1.2, ease = "elastic.out(1, 0.35)", } = options;
|
|
23
|
+
return guard(options, () => {
|
|
24
|
+
const prevTransform = els.map((el) => el.style.transform);
|
|
25
|
+
const listeners = [];
|
|
26
|
+
els.forEach((el) => {
|
|
27
|
+
const onMove = (e) => {
|
|
28
|
+
const ptr = e;
|
|
29
|
+
const r = el.getBoundingClientRect();
|
|
30
|
+
const dx = ptr.clientX - (r.left + r.width / 2);
|
|
31
|
+
const dy = ptr.clientY - (r.top + r.height / 2);
|
|
32
|
+
const nx = r.width ? dx / (r.width / 2) : 0; // -1 … 1 across the box
|
|
33
|
+
gsap.to(el, {
|
|
34
|
+
x: dx * strength,
|
|
35
|
+
y: dy * strength,
|
|
36
|
+
rotation: rotation ? nx * rotation : 0,
|
|
37
|
+
scale,
|
|
38
|
+
duration: 0.4,
|
|
39
|
+
ease: "power3.out",
|
|
40
|
+
overwrite: "auto",
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
const onLeave = () => {
|
|
44
|
+
gsap.to(el, { x: 0, y: 0, rotation: 0, scale: 1, duration, ease, overwrite: "auto" });
|
|
45
|
+
};
|
|
46
|
+
el.addEventListener("pointermove", onMove);
|
|
47
|
+
el.addEventListener("pointerleave", onLeave);
|
|
48
|
+
listeners.push({ el, type: "pointermove", fn: onMove }, { el, type: "pointerleave", fn: onLeave });
|
|
49
|
+
});
|
|
50
|
+
return () => {
|
|
51
|
+
listeners.forEach(({ el, type, fn }) => el.removeEventListener(type, fn));
|
|
52
|
+
killTweens(els);
|
|
53
|
+
els.forEach((el, i) => {
|
|
54
|
+
el.style.transform = prevTransform[i];
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=magnetic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"magnetic.js","sourceRoot":"","sources":["../../src/effects/magnetic.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAgB1C,MAAM,UAAU,QAAQ,CAAC,MAAkB,EAAE,UAA2B,EAAE;IACxE,QAAQ,EAAE,CAAC;IAEX,MAAM,GA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-18,6 +18,8 @@ export interface MediaSettleOptions extends CommonOptions {
|
|
|
18
18
|
start?: string;
|
|
19
19
|
/** ScrollTrigger end position (scrub mode). @default "bottom top" */
|
|
20
20
|
end?: string;
|
|
21
|
+
/** Re-settle when leaving / re-entering the viewport (enter mode). @default false */
|
|
22
|
+
replay?: boolean;
|
|
21
23
|
/**
|
|
22
24
|
* Bind the settle to scroll progress instead of playing it on enter —
|
|
23
25
|
* number = scrub smoothing seconds, `true` = immediate. unset = one-shot.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media-settle.d.ts","sourceRoot":"","sources":["../../src/effects/media-settle.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"media-settle.d.ts","sourceRoot":"","sources":["../../src/effects/media-settle.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE3E,MAAM,WAAW,kBAAmB,SAAQ,aAAa;IACvD,wDAAwD;IACxD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,uCAAuC;IACvC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,yCAAyC;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,sDAAsD;IACtD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gDAAgD;IAChD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4EAA4E;IAC5E,IAAI,CAAC,EAAE,QAAQ,GAAG,WAAW,CAAC;IAC9B,uDAAuD;IACvD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qEAAqE;IACrE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,qFAAqF;IACrF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1B;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,GAAE,kBAAuB,GAAG,OAAO,CA2DzF"}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* mediaSettle("[data-settle]", { from: 1.3 }); // on enter
|
|
9
9
|
* mediaSettle("[data-settle]", { scrub: 0.5 }); // scroll-bound
|
|
10
|
+
* mediaSettle("[data-settle]", { replay: true }); // reverse on leave-back, replay on re-enter
|
|
10
11
|
*
|
|
11
12
|
* destroy() kills the tween and restores the original scale.
|
|
12
13
|
*/
|
|
@@ -15,7 +16,7 @@ import { guard } from "../core/guard.js";
|
|
|
15
16
|
import { toArray } from "../core/util.js";
|
|
16
17
|
export function mediaSettle(target, options = {}) {
|
|
17
18
|
initGSAP();
|
|
18
|
-
const { from = 1.15, duration = 1.5, ease = "power2.out", origin = "center", stagger = 0.06, delay = 0, mode = "scroll", start = "top 75%", end = "bottom top", scrub, } = options;
|
|
19
|
+
const { from = 1.15, duration = 1.5, ease = "power2.out", origin = "center", stagger = 0.06, delay = 0, mode = "scroll", start = "top 75%", end = "bottom top", replay = false, scrub, } = options;
|
|
19
20
|
const els = toArray(target);
|
|
20
21
|
if (!els.length)
|
|
21
22
|
return () => { };
|
|
@@ -36,7 +37,9 @@ export function mediaSettle(target, options = {}) {
|
|
|
36
37
|
vars.duration = duration;
|
|
37
38
|
vars.ease = ease;
|
|
38
39
|
if (mode === "scroll") {
|
|
39
|
-
vars.scrollTrigger =
|
|
40
|
+
vars.scrollTrigger = replay
|
|
41
|
+
? { trigger: els[0], start, toggleActions: "play reverse play reverse" }
|
|
42
|
+
: { trigger: els[0], start, once: true };
|
|
40
43
|
}
|
|
41
44
|
}
|
|
42
45
|
const tween = gsap.fromTo(els, { scale: from, transformOrigin: origin }, { ...vars, immediateRender: true });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media-settle.js","sourceRoot":"","sources":["../../src/effects/media-settle.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
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K;gBACL,GAAG;gBACH,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK;aACrC,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;YACzB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;YACjB,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACtB,IAAI,CAAC,aAAa,GAAG,MAAM;oBACzB,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,aAAa,EAAE,2BAA2B,EAAE;oBACxE,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;YAC7C,CAAC;QACH,CAAC;QAED,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CACvB,GAAG,EACH,EAAE,KAAK,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,EAAE,EACxC,EAAE,GAAG,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,CACnC,CAAC;QACF,aAAa,CAAC,OAAO,EAAE,CAAC;QAExB,OAAO,GAAG,EAAE;YACV,KAAK,CAAC,aAAa,EAAE,IAAI,EAAE,CAAC;YAC5B,KAAK,CAAC,IAAI,EAAE,CAAC;YACb,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,UAAU,EAAE,2BAA2B,EAAE,CAAC,CAAC;YAC3D,aAAa,CAAC,OAAO,EAAE,CAAC;QAC1B,CAAC,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { CommonOptions, Destroy, TargetLike } from "../core/types.js";
|
|
2
|
+
export interface ReelTextOptions extends CommonOptions {
|
|
3
|
+
/** `'immediate'` rolls on mount; `'scroll'` rolls on viewport enter. @default `"immediate"` */
|
|
4
|
+
mode?: "immediate" | "scroll";
|
|
5
|
+
/** ScrollTrigger start (only with `mode: "scroll"`). @default `"top 85%"` */
|
|
6
|
+
start?: string;
|
|
7
|
+
/** Ghost frames per character before the final glyph. @default 4 */
|
|
8
|
+
frames?: number;
|
|
9
|
+
/** Roll duration per character, seconds. @default 0.8 */
|
|
10
|
+
duration?: number;
|
|
11
|
+
/** Stagger between characters, seconds. @default 0.05 */
|
|
12
|
+
stagger?: number;
|
|
13
|
+
/** GSAP ease for the roll. @default `"power4.out"` */
|
|
14
|
+
ease?: string;
|
|
15
|
+
/** Re-arm on every scroll re-entry instead of playing once. @default false */
|
|
16
|
+
replay?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare function reelText(target: TargetLike, options?: ReelTextOptions): Destroy;
|
|
19
|
+
//# sourceMappingURL=reel-text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reel-text.d.ts","sourceRoot":"","sources":["../../src/effects/reel-text.ts"],"names":[],"mappings":"AAmCA,OAAO,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE3E,MAAM,WAAW,eAAgB,SAAQ,aAAa;IACpD,+FAA+F;IAC/F,IAAI,CAAC,EAAE,WAAW,GAAG,QAAQ,CAAC;IAC9B,6EAA6E;IAC7E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oEAAoE;IACpE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,yDAAyD;IACzD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yDAAyD;IACzD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sDAAsD;IACtD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,8EAA8E;IAC9E,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAkCD,wBAAgB,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,GAAE,eAAoB,GAAG,OAAO,CA6HnF"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reel text — the per-character odometer roll.
|
|
3
|
+
*
|
|
4
|
+
* Every character gets its own overflow-hidden mask and a vertical strip of
|
|
5
|
+
* ghost glyphs stacked under the final one; the strips roll upward (staggered
|
|
6
|
+
* left→right) and land on the real text. This is the DOM twin of a shader
|
|
7
|
+
* slot-reel: character cells spun per glyph (`u_roll`/`u_spin` style), ported
|
|
8
|
+
* to plain GSAP so it needs no canvas. Why it is shaped this way:
|
|
9
|
+
*
|
|
10
|
+
* - **Built eagerly, rolled on trigger.** The masks exist as soon as the
|
|
11
|
+
* effect mounts (so layout is stable and tests can see the structure); the
|
|
12
|
+
* roll plays immediately or on scroll-enter. On completion the original
|
|
13
|
+
* `innerHTML` is restored — screen readers and copy/paste see clean text —
|
|
14
|
+
* and a `replay` re-entry re-splits from scratch. The ScrollTrigger is
|
|
15
|
+
* registered **once per element**, outside the rebuild path, so replay
|
|
16
|
+
* never stacks triggers.
|
|
17
|
+
* - **Width probed, never guessed.** Each wrapper's width is measured from
|
|
18
|
+
* the *final* glyph (hidden probe in the body) so ghost frames of a
|
|
19
|
+
* different width can't jitter the line while it spins. jsdom reports 0 —
|
|
20
|
+
* the wrapper then shrink-wraps, which is why the unit smoke still passes.
|
|
21
|
+
* - **Same-case ghosts.** Uppercase rolls through the uppercase alphabet,
|
|
22
|
+
* lowercase through lowercase, digits through digits — the line never
|
|
23
|
+
* changes colour/shape mid-roll the way mixed-case ghosts would. Spaces and
|
|
24
|
+
* punctuation stay as plain text (they don't spin).
|
|
25
|
+
* - **Fidelity.** `destroy()` kills the timeline + trigger, clears the stamp
|
|
26
|
+
* and puts the original `innerHTML` back byte for byte.
|
|
27
|
+
*
|
|
28
|
+
* reelText("[data-reel]", { mode: "scroll", frames: 4 })
|
|
29
|
+
*
|
|
30
|
+
* CSS: nothing required — masks, strip and frame heights are inline. Give the
|
|
31
|
+
* target the `line-height` you want the cells to inherit.
|
|
32
|
+
*/
|
|
33
|
+
import { gsap, ScrollTrigger, initGSAP } from "../core/gsap.js";
|
|
34
|
+
import { guard } from "../core/guard.js";
|
|
35
|
+
import { toArray } from "../core/util.js";
|
|
36
|
+
const UPPERCASE = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
37
|
+
const LOWERCASE = "abcdefghijklmnopqrstuvwxyz";
|
|
38
|
+
const DIGITS = "0123456789";
|
|
39
|
+
/** Only alphanumerics get a reel; spaces/punctuation pass through untouched. */
|
|
40
|
+
const spins = (ch) => /[A-Za-z0-9]/.test(ch);
|
|
41
|
+
const ghostsFor = (ch, count) => {
|
|
42
|
+
const pool = /[A-Z]/.test(ch) ? UPPERCASE : /[a-z]/.test(ch) ? LOWERCASE : DIGITS;
|
|
43
|
+
let out = "";
|
|
44
|
+
for (let i = 0; i < count; i++)
|
|
45
|
+
out += pool[Math.floor(Math.random() * pool.length)];
|
|
46
|
+
return out;
|
|
47
|
+
};
|
|
48
|
+
/** Width of a glyph — 0 in jsdom, where wrappers may shrink-wrap instead. */
|
|
49
|
+
const measureGlyph = (ch, sample) => {
|
|
50
|
+
const doc = sample.ownerDocument;
|
|
51
|
+
if (!doc.body)
|
|
52
|
+
return 0;
|
|
53
|
+
const probe = doc.createElement("span");
|
|
54
|
+
probe.style.cssText = "position:absolute;visibility:hidden;white-space:pre;";
|
|
55
|
+
probe.textContent = ch;
|
|
56
|
+
doc.body.appendChild(probe);
|
|
57
|
+
const w = probe.getBoundingClientRect().width;
|
|
58
|
+
probe.remove();
|
|
59
|
+
return Math.round(w);
|
|
60
|
+
};
|
|
61
|
+
export function reelText(target, options = {}) {
|
|
62
|
+
initGSAP();
|
|
63
|
+
const els = toArray(target);
|
|
64
|
+
if (!els.length)
|
|
65
|
+
return () => { };
|
|
66
|
+
const { mode = "immediate", start = "top 85%", frames = 4, duration = 0.8, stagger = 0.05, ease = "power4.out", replay = false, } = options;
|
|
67
|
+
return guard(options, () => {
|
|
68
|
+
const cells = [];
|
|
69
|
+
const timelines = new Map();
|
|
70
|
+
const triggers = [];
|
|
71
|
+
/** Unwind to the original markup (on completion and on destroy). */
|
|
72
|
+
const restore = (el) => {
|
|
73
|
+
const i = cells.findIndex((c) => c.el === el);
|
|
74
|
+
if (i < 0)
|
|
75
|
+
return;
|
|
76
|
+
el.innerHTML = cells[i].original;
|
|
77
|
+
delete el.dataset.akReel;
|
|
78
|
+
cells.splice(i, 1);
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Split one element into masks + a paused roll timeline.
|
|
82
|
+
* Returns the timeline; the caller decides when (and whether) it plays.
|
|
83
|
+
*/
|
|
84
|
+
const build = (el) => {
|
|
85
|
+
const text = el.textContent ?? "";
|
|
86
|
+
if (!text.trim())
|
|
87
|
+
return null;
|
|
88
|
+
timelines.get(el)?.kill(); // a finished roll from a previous entry
|
|
89
|
+
// Keep the FIRST original: a second build must not snapshot masked HTML.
|
|
90
|
+
if (!cells.some((c) => c.el === el))
|
|
91
|
+
cells.push({ el, original: el.innerHTML });
|
|
92
|
+
const lineHeight = parseFloat(getComputedStyle(el).lineHeight) || el.getBoundingClientRect().height || 16;
|
|
93
|
+
// Original markup → per-char segments (the element must be plain text).
|
|
94
|
+
el.textContent = "";
|
|
95
|
+
const strips = [];
|
|
96
|
+
const ends = [];
|
|
97
|
+
for (const ch of [...text]) {
|
|
98
|
+
if (!spins(ch)) {
|
|
99
|
+
el.appendChild(el.ownerDocument.createTextNode(ch));
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
const wrapper = el.ownerDocument.createElement("span");
|
|
103
|
+
wrapper.className = "ak-reel__ch";
|
|
104
|
+
wrapper.style.cssText = `display:inline-block;overflow:hidden;vertical-align:top;height:${lineHeight}px;`;
|
|
105
|
+
const width = measureGlyph(ch, el);
|
|
106
|
+
if (width > 0)
|
|
107
|
+
wrapper.style.width = `${width}px`;
|
|
108
|
+
const strip = el.ownerDocument.createElement("span");
|
|
109
|
+
strip.className = "ak-reel__strip";
|
|
110
|
+
strip.style.cssText = "display:flex;flex-direction:column;will-change:transform;";
|
|
111
|
+
for (const frame of ghostsFor(ch, frames) + ch) {
|
|
112
|
+
const frameEl = el.ownerDocument.createElement("span");
|
|
113
|
+
frameEl.style.cssText = `display:flex;align-items:center;justify-content:center;height:${lineHeight}px;flex:none;`;
|
|
114
|
+
frameEl.textContent = frame;
|
|
115
|
+
strip.appendChild(frameEl);
|
|
116
|
+
}
|
|
117
|
+
wrapper.appendChild(strip);
|
|
118
|
+
el.appendChild(wrapper);
|
|
119
|
+
strips.push(strip);
|
|
120
|
+
ends.push(-frames * lineHeight);
|
|
121
|
+
}
|
|
122
|
+
el.dataset.akReel = "true";
|
|
123
|
+
const tl = gsap.timeline({ paused: true, onComplete: () => restore(el) });
|
|
124
|
+
strips.forEach((strip, i) => {
|
|
125
|
+
tl.to(strip, { y: ends[i], duration, ease }, i * stagger);
|
|
126
|
+
});
|
|
127
|
+
timelines.set(el, tl);
|
|
128
|
+
return tl;
|
|
129
|
+
};
|
|
130
|
+
els.forEach((el) => {
|
|
131
|
+
const tl = build(el);
|
|
132
|
+
if (!tl)
|
|
133
|
+
return;
|
|
134
|
+
if (mode === "immediate") {
|
|
135
|
+
tl.play(0);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
// Registered once per element — rebuilds on replay reuse this trigger.
|
|
139
|
+
triggers.push(ScrollTrigger.create({
|
|
140
|
+
trigger: el,
|
|
141
|
+
start,
|
|
142
|
+
once: !replay,
|
|
143
|
+
onEnter: () => {
|
|
144
|
+
// Restored after the last roll (or never started) → rebuild first.
|
|
145
|
+
const active = el.dataset.akReel === "true" ? timelines.get(el) : build(el);
|
|
146
|
+
active?.play(0);
|
|
147
|
+
},
|
|
148
|
+
}));
|
|
149
|
+
});
|
|
150
|
+
return () => {
|
|
151
|
+
triggers.forEach((st) => st.kill());
|
|
152
|
+
triggers.length = 0;
|
|
153
|
+
timelines.forEach((tl) => tl.kill());
|
|
154
|
+
timelines.clear();
|
|
155
|
+
cells.slice().forEach((cell) => {
|
|
156
|
+
cell.el.innerHTML = cell.original;
|
|
157
|
+
delete cell.el.dataset.akReel;
|
|
158
|
+
});
|
|
159
|
+
cells.length = 0;
|
|
160
|
+
};
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
//# sourceMappingURL=reel-text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reel-text.js","sourceRoot":"","sources":["../../src/effects/reel-text.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAyB1C,MAAM,SAAS,GAAG,4BAA4B,CAAC;AAC/C,MAAM,SAAS,GAAG,4BAA4B,CAAC;AAC/C,MAAM,MAAM,GAAG,YAAY,CAAC;AAE5B,gFAAgF;AAChF,MAAM,KAAK,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAErD,MAAM,SAAS,GAAG,CAAC,EAAU,EAAE,KAAa,EAAU,EAAE;IACtD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC;IAClF,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE;QAAE,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IACrF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AC,CAAC;oBAC5E,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;gBAClB,CAAC;aACF,CAAC,CACH,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,OAAO,GAAG,EAAE;YACV,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC;YACpC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;YACpB,SAAS,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC;YACrC,SAAS,CAAC,KAAK,EAAE,CAAC;YAClB,KAAK,CAAC,KAAK,EAAE,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;gBAC7B,IAAI,CAAC,EAAE,CAAC,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC;gBAClC,OAAO,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC;YAChC,CAAC,CAAC,CAAC;YACH,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;QACnB,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* anim-kit — modular animation library
|
|
2
|
+
* anim-kit — modular animation library by kalakritico.in.
|
|
3
3
|
*
|
|
4
4
|
* Core:
|
|
5
5
|
* smoothScroll() Lenis + ScrollTrigger bridge (lerp 0.08)
|
|
@@ -24,15 +24,19 @@
|
|
|
24
24
|
* Infinite / loops:
|
|
25
25
|
* marquee() dual-row constant-speed marquee
|
|
26
26
|
* dragStrip() infinite draggable carousel with rotation
|
|
27
|
+
* dragRail() bounded drag rail — inertia, tanh rubber-band, wheel
|
|
27
28
|
* rollText() rolling word rotator (seamless row loop)
|
|
28
29
|
*
|
|
29
30
|
* Text extras:
|
|
30
31
|
* scrambleText() decode / cipher reveal per character
|
|
32
|
+
* reelText() per-character odometer roll (masked reel strips)
|
|
33
|
+
* flipWords() words that glide between two layouts (FLIP)
|
|
31
34
|
*
|
|
32
35
|
* Micro-interactions:
|
|
33
36
|
* liquidButton() SVG wave flood on hover
|
|
34
37
|
* underlineLink() underline wipe on hover
|
|
35
38
|
* cursorFollower() spring-follow cursor tag
|
|
39
|
+
* magnetic() elements that pull toward the pointer and spring back
|
|
36
40
|
* counter() tabular number ticker (timed or scroll-progress)
|
|
37
41
|
* audioBars() equaliser visualiser
|
|
38
42
|
* themeReveal() View Transitions circular wipe
|
|
@@ -54,7 +58,7 @@ export type { MaskRevealOptions } from "./effects/mask-reveal.js";
|
|
|
54
58
|
export { unfoldReveal } from "./effects/unfold-reveal.js";
|
|
55
59
|
export type { UnfoldRevealOptions } from "./effects/unfold-reveal.js";
|
|
56
60
|
export { clipWipe } from "./effects/clip-wipe.js";
|
|
57
|
-
export type { ClipWipeOptions } from "./effects/clip-wipe.js";
|
|
61
|
+
export type { ClipWipeOptions, ClipWipeFrom } from "./effects/clip-wipe.js";
|
|
58
62
|
export { parallax } from "./effects/parallax.js";
|
|
59
63
|
export type { ParallaxOptions } from "./effects/parallax.js";
|
|
60
64
|
export { horizontalScroll } from "./effects/horizontal-scroll.js";
|
|
@@ -75,14 +79,22 @@ export { marquee } from "./effects/marquee.js";
|
|
|
75
79
|
export type { MarqueeOptions } from "./effects/marquee.js";
|
|
76
80
|
export { rollText } from "./effects/roll-text.js";
|
|
77
81
|
export type { RollTextOptions } from "./effects/roll-text.js";
|
|
82
|
+
export { reelText } from "./effects/reel-text.js";
|
|
83
|
+
export type { ReelTextOptions } from "./effects/reel-text.js";
|
|
78
84
|
export { dragStrip } from "./effects/drag-strip.js";
|
|
79
85
|
export type { DragStripOptions } from "./effects/drag-strip.js";
|
|
86
|
+
export { dragRail } from "./effects/drag-rail.js";
|
|
87
|
+
export type { DragRailOptions } from "./effects/drag-rail.js";
|
|
80
88
|
export { scrambleText } from "./effects/scramble-text.js";
|
|
81
89
|
export type { ScrambleTextOptions } from "./effects/scramble-text.js";
|
|
90
|
+
export { flipWords } from "./effects/flip-words.js";
|
|
91
|
+
export type { FlipWordsOptions } from "./effects/flip-words.js";
|
|
82
92
|
export { liquidButton, underlineLink } from "./effects/liquid-button.js";
|
|
83
93
|
export type { LiquidButtonOptions } from "./effects/liquid-button.js";
|
|
84
94
|
export { cursorFollower } from "./effects/cursor-follower.js";
|
|
85
95
|
export type { CursorFollowerOptions } from "./effects/cursor-follower.js";
|
|
96
|
+
export { magnetic } from "./effects/magnetic.js";
|
|
97
|
+
export type { MagneticOptions } from "./effects/magnetic.js";
|
|
86
98
|
export { counter, audioBars } from "./effects/counter.js";
|
|
87
99
|
export type { CounterOptions, AudioBarsOptions, AudioBarsHandle } from "./effects/counter.js";
|
|
88
100
|
export { themeReveal } from "./effects/theme-reveal.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAGH,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,cAAc,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACxH,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AACvF,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5E,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;A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AAM,uBAAuB,CAAC;AACjD,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC1D,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE9F,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAElG,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAEvF,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,YAAY,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* anim-kit — modular animation library
|
|
2
|
+
* anim-kit — modular animation library by kalakritico.in.
|
|
3
3
|
*
|
|
4
4
|
* Core:
|
|
5
5
|
* smoothScroll() Lenis + ScrollTrigger bridge (lerp 0.08)
|
|
@@ -24,15 +24,19 @@
|
|
|
24
24
|
* Infinite / loops:
|
|
25
25
|
* marquee() dual-row constant-speed marquee
|
|
26
26
|
* dragStrip() infinite draggable carousel with rotation
|
|
27
|
+
* dragRail() bounded drag rail — inertia, tanh rubber-band, wheel
|
|
27
28
|
* rollText() rolling word rotator (seamless row loop)
|
|
28
29
|
*
|
|
29
30
|
* Text extras:
|
|
30
31
|
* scrambleText() decode / cipher reveal per character
|
|
32
|
+
* reelText() per-character odometer roll (masked reel strips)
|
|
33
|
+
* flipWords() words that glide between two layouts (FLIP)
|
|
31
34
|
*
|
|
32
35
|
* Micro-interactions:
|
|
33
36
|
* liquidButton() SVG wave flood on hover
|
|
34
37
|
* underlineLink() underline wipe on hover
|
|
35
38
|
* cursorFollower() spring-follow cursor tag
|
|
39
|
+
* magnetic() elements that pull toward the pointer and spring back
|
|
36
40
|
* counter() tabular number ticker (timed or scroll-progress)
|
|
37
41
|
* audioBars() equaliser visualiser
|
|
38
42
|
* themeReveal() View Transitions circular wipe
|
|
@@ -61,12 +65,16 @@ export { logoReveal } from "./effects/logo-reveal.js";
|
|
|
61
65
|
/* ---- loops ---- */
|
|
62
66
|
export { marquee } from "./effects/marquee.js";
|
|
63
67
|
export { rollText } from "./effects/roll-text.js";
|
|
68
|
+
export { reelText } from "./effects/reel-text.js";
|
|
64
69
|
export { dragStrip } from "./effects/drag-strip.js";
|
|
70
|
+
export { dragRail } from "./effects/drag-rail.js";
|
|
65
71
|
/* ---- text extras ---- */
|
|
66
72
|
export { scrambleText } from "./effects/scramble-text.js";
|
|
73
|
+
export { flipWords } from "./effects/flip-words.js";
|
|
67
74
|
/* ---- micro-interactions ---- */
|
|
68
75
|
export { liquidButton, underlineLink } from "./effects/liquid-button.js";
|
|
69
76
|
export { cursorFollower } from "./effects/cursor-follower.js";
|
|
77
|
+
export { magnetic } from "./effects/magnetic.js";
|
|
70
78
|
export { counter, audioBars } from "./effects/counter.js";
|
|
71
79
|
export { themeReveal } from "./effects/theme-reveal.js";
|
|
72
80
|
export { menuOverlay } from "./effects/menu-overlay.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH,oBAAoB;AACpB,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,cAAc,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAA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B,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAG1D,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAGpD,kCAAkC;AAClC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAGzE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAG9D,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGjD,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAG1D,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAGxD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAGxD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@cosmictraveler002/anim-kit/three` — the WebGL entry.
|
|
3
|
+
*
|
|
4
|
+
* Everything here renders media through **three.js**, which is an *optional
|
|
5
|
+
* peer dependency*: install `three` alongside anim-kit to use this subpath.
|
|
6
|
+
* The core barrel (`@cosmictraveler002/anim-kit`) never imports three, so
|
|
7
|
+
* plain DOM/scroll users keep a gsap+lenis-only dependency tree.
|
|
8
|
+
*
|
|
9
|
+
* import { webglMedia } from "@cosmictraveler002/anim-kit/three";
|
|
10
|
+
*/
|
|
11
|
+
export { webglMedia } from "./webgl-media.js";
|
|
12
|
+
export type { WebglMediaOptions } from "./webgl-media.js";
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/three/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,YAAY,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@cosmictraveler002/anim-kit/three` — the WebGL entry.
|
|
3
|
+
*
|
|
4
|
+
* Everything here renders media through **three.js**, which is an *optional
|
|
5
|
+
* peer dependency*: install `three` alongside anim-kit to use this subpath.
|
|
6
|
+
* The core barrel (`@cosmictraveler002/anim-kit`) never imports three, so
|
|
7
|
+
* plain DOM/scroll users keep a gsap+lenis-only dependency tree.
|
|
8
|
+
*
|
|
9
|
+
* import { webglMedia } from "@cosmictraveler002/anim-kit/three";
|
|
10
|
+
*/
|
|
11
|
+
export { webglMedia } from "./webgl-media.js";
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/three/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC"}
|