@cosmictraveler002/anim-kit 1.0.0 → 1.2.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 +275 -50
- package/dist/anim-kit.standalone.js +18 -8
- package/dist/anim-kit.standalone.js.map +1 -1
- package/dist/core/gsap.d.ts +2 -1
- package/dist/core/gsap.d.ts.map +1 -1
- package/dist/core/gsap.js +3 -2
- package/dist/core/gsap.js.map +1 -1
- package/dist/core/split.d.ts.map +1 -1
- package/dist/core/split.js +15 -2
- package/dist/core/split.js.map +1 -1
- package/dist/effects/clip-wipe.d.ts +31 -0
- package/dist/effects/clip-wipe.d.ts.map +1 -0
- package/dist/effects/clip-wipe.js +82 -0
- package/dist/effects/clip-wipe.js.map +1 -0
- package/dist/effects/counter.d.ts +9 -0
- package/dist/effects/counter.d.ts.map +1 -1
- package/dist/effects/counter.js +17 -7
- package/dist/effects/counter.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/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/line-reveal.d.ts +6 -2
- package/dist/effects/line-reveal.d.ts.map +1 -1
- package/dist/effects/line-reveal.js +8 -4
- package/dist/effects/line-reveal.js.map +1 -1
- 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 +30 -0
- package/dist/effects/media-settle.d.ts.map +1 -0
- package/dist/effects/media-settle.js +55 -0
- package/dist/effects/media-settle.js.map +1 -0
- package/dist/effects/roll-text.d.ts +13 -0
- package/dist/effects/roll-text.d.ts.map +1 -0
- package/dist/effects/roll-text.js +91 -0
- package/dist/effects/roll-text.js.map +1 -0
- package/dist/effects/scramble-text.d.ts +17 -0
- package/dist/effects/scramble-text.d.ts.map +1 -0
- package/dist/effects/scramble-text.js +93 -0
- package/dist/effects/scramble-text.js.map +1 -0
- package/dist/effects/unfold-reveal.d.ts +23 -0
- package/dist/effects/unfold-reveal.d.ts.map +1 -0
- package/dist/effects/unfold-reveal.js +53 -0
- package/dist/effects/unfold-reveal.js.map +1 -0
- package/dist/index.d.ts +25 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -2
- package/dist/index.js.map +1 -1
- package/dist/styles/anim-kit.css +22 -0
- package/package.json +6 -3
- package/src/core/gsap.ts +3 -2
- package/src/core/split.ts +16 -2
- package/src/effects/clip-wipe.ts +141 -0
- package/src/effects/counter.ts +26 -6
- package/src/effects/cursor-follower.ts +21 -4
- package/src/effects/flip-words.ts +148 -0
- package/src/effects/line-reveal.ts +12 -5
- package/src/effects/magnetic.ts +87 -0
- package/src/effects/media-settle.ts +106 -0
- package/src/effects/roll-text.ts +118 -0
- package/src/effects/scramble-text.ts +122 -0
- package/src/effects/unfold-reveal.ts +92 -0
- package/src/index.ts +33 -2
- package/src/styles/anim-kit.css +22 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unfold reveal — blocks that grow open from an edge.
|
|
3
|
+
*
|
|
4
|
+
* `scaleY: 0 → 1` from the top (or bottom) edge for a vertical unfold,
|
|
5
|
+
* `scaleX: 0 → 1` from the left for a horizontal one — the staggered block
|
|
6
|
+
* grow-in used for labels, headings and buttons as a section enters.
|
|
7
|
+
*
|
|
8
|
+
* unfoldReveal("[data-unfold]", { axis: "y", origin: "top" });
|
|
9
|
+
* unfoldReveal("[data-unfold-x]", { axis: "x", origin: "left" });
|
|
10
|
+
*
|
|
11
|
+
* Targets stagger together off the first match's trigger. destroy() kills the
|
|
12
|
+
* tween and clears the transform, so elements rest exactly as authored.
|
|
13
|
+
*/
|
|
14
|
+
import { gsap, ScrollTrigger, initGSAP } from "../core/gsap.js";
|
|
15
|
+
import { guard } from "../core/guard.js";
|
|
16
|
+
import { toArray } from "../core/util.js";
|
|
17
|
+
import type { CommonOptions, Destroy, TargetLike } from "../core/types.js";
|
|
18
|
+
|
|
19
|
+
export interface UnfoldRevealOptions extends CommonOptions {
|
|
20
|
+
/** Which axis grows open. @default "y" */
|
|
21
|
+
axis?: "y" | "x";
|
|
22
|
+
/** transformOrigin — defaults to "top" (y) / "left" (x). */
|
|
23
|
+
origin?: string;
|
|
24
|
+
/** Animation duration, seconds. @default 0.7 */
|
|
25
|
+
duration?: number;
|
|
26
|
+
/** GSAP ease. @default "power3.out" */
|
|
27
|
+
ease?: string;
|
|
28
|
+
/** Stagger between targets, seconds. @default 0.08 */
|
|
29
|
+
stagger?: number;
|
|
30
|
+
/** Delay before playing, seconds. @default 0 */
|
|
31
|
+
delay?: number;
|
|
32
|
+
/** "scroll" plays on enter, "immediate" plays at once. @default "scroll" */
|
|
33
|
+
mode?: "scroll" | "immediate";
|
|
34
|
+
/** ScrollTrigger start position. @default "top 85%" */
|
|
35
|
+
start?: string;
|
|
36
|
+
/** Re-unfold when leaving / re-entering the viewport. @default false */
|
|
37
|
+
replay?: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function unfoldReveal(target: TargetLike, options: UnfoldRevealOptions = {}): Destroy {
|
|
41
|
+
initGSAP();
|
|
42
|
+
|
|
43
|
+
const {
|
|
44
|
+
axis = "y",
|
|
45
|
+
origin,
|
|
46
|
+
duration = 0.7,
|
|
47
|
+
ease = "power3.out",
|
|
48
|
+
stagger = 0.08,
|
|
49
|
+
delay = 0,
|
|
50
|
+
mode = "scroll",
|
|
51
|
+
start = "top 85%",
|
|
52
|
+
replay = false,
|
|
53
|
+
} = options;
|
|
54
|
+
|
|
55
|
+
const els = toArray<HTMLElement>(target);
|
|
56
|
+
if (!els.length) return () => {};
|
|
57
|
+
|
|
58
|
+
return guard(options, run);
|
|
59
|
+
|
|
60
|
+
function run(): Destroy {
|
|
61
|
+
const prop = axis === "x" ? "scaleX" : "scaleY";
|
|
62
|
+
const from = origin ?? (axis === "x" ? "left" : "top");
|
|
63
|
+
|
|
64
|
+
gsap.set(els, { [prop]: 0, transformOrigin: from });
|
|
65
|
+
|
|
66
|
+
const vars: gsap.TweenVars = {
|
|
67
|
+
[prop]: 1,
|
|
68
|
+
duration,
|
|
69
|
+
ease,
|
|
70
|
+
stagger,
|
|
71
|
+
delay,
|
|
72
|
+
overwrite: "auto",
|
|
73
|
+
};
|
|
74
|
+
if (mode === "scroll") {
|
|
75
|
+
vars.scrollTrigger = {
|
|
76
|
+
trigger: els[0],
|
|
77
|
+
start,
|
|
78
|
+
toggleActions: replay ? "play reverse play reverse" : "play none none none",
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const tween = gsap.to(els, vars);
|
|
83
|
+
ScrollTrigger.refresh();
|
|
84
|
+
|
|
85
|
+
return () => {
|
|
86
|
+
tween.scrollTrigger?.kill();
|
|
87
|
+
tween.kill();
|
|
88
|
+
gsap.set(els, { clearProps: "transform,transformOrigin" });
|
|
89
|
+
ScrollTrigger.refresh();
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -7,26 +7,35 @@
|
|
|
7
7
|
* split() text splitting with mask support
|
|
8
8
|
*
|
|
9
9
|
* Scroll effects:
|
|
10
|
-
* lineReveal() masked staggered text reveal
|
|
10
|
+
* lineReveal() masked staggered text reveal (lines or chars)
|
|
11
11
|
* maskReveal() inline overflow-hidden heading reveal
|
|
12
12
|
* revealRule() line that draws to full width
|
|
13
|
+
* unfoldReveal() blocks that scale open from an edge
|
|
14
|
+
* clipWipe() clip-path inset wipe reveal
|
|
13
15
|
* parallax() data-speed parallax
|
|
14
16
|
* horizontalScroll() pinned horizontal gallery
|
|
15
17
|
* stackedCards() / stackedCardsPinned() pinned card deck
|
|
16
18
|
* scatterText() pinned horizontal band with per-char settle
|
|
17
19
|
* heroShrink() media that scales down as it scrolls away
|
|
20
|
+
* mediaSettle() media that settles from a larger entrance scale
|
|
18
21
|
* navHide() header that hides on scroll-down
|
|
19
22
|
* logoReveal() SVG wordmark assembling letter by letter
|
|
20
23
|
*
|
|
21
24
|
* Infinite / loops:
|
|
22
25
|
* marquee() dual-row constant-speed marquee
|
|
23
26
|
* dragStrip() infinite draggable carousel with rotation
|
|
27
|
+
* rollText() rolling word rotator (seamless row loop)
|
|
28
|
+
*
|
|
29
|
+
* Text extras:
|
|
30
|
+
* scrambleText() decode / cipher reveal per character
|
|
31
|
+
* flipWords() words that glide between two layouts (FLIP)
|
|
24
32
|
*
|
|
25
33
|
* Micro-interactions:
|
|
26
34
|
* liquidButton() SVG wave flood on hover
|
|
27
35
|
* underlineLink() underline wipe on hover
|
|
28
36
|
* cursorFollower() spring-follow cursor tag
|
|
29
|
-
*
|
|
37
|
+
* magnetic() elements that pull toward the pointer and spring back
|
|
38
|
+
* counter() tabular number ticker (timed or scroll-progress)
|
|
30
39
|
* audioBars() equaliser visualiser
|
|
31
40
|
* themeReveal() View Transitions circular wipe
|
|
32
41
|
* menuOverlay() clip-path curtain menu
|
|
@@ -50,6 +59,12 @@ export type { LineRevealOptions } from "./effects/line-reveal.js";
|
|
|
50
59
|
export { maskReveal, revealRule } from "./effects/mask-reveal.js";
|
|
51
60
|
export type { MaskRevealOptions } from "./effects/mask-reveal.js";
|
|
52
61
|
|
|
62
|
+
export { unfoldReveal } from "./effects/unfold-reveal.js";
|
|
63
|
+
export type { UnfoldRevealOptions } from "./effects/unfold-reveal.js";
|
|
64
|
+
|
|
65
|
+
export { clipWipe } from "./effects/clip-wipe.js";
|
|
66
|
+
export type { ClipWipeOptions, ClipWipeFrom } from "./effects/clip-wipe.js";
|
|
67
|
+
|
|
53
68
|
export { parallax } from "./effects/parallax.js";
|
|
54
69
|
export type { ParallaxOptions } from "./effects/parallax.js";
|
|
55
70
|
|
|
@@ -65,6 +80,9 @@ export type { ScatterTextOptions } from "./effects/scatter-text.js";
|
|
|
65
80
|
export { heroShrink } from "./effects/hero-shrink.js";
|
|
66
81
|
export type { HeroShrinkOptions } from "./effects/hero-shrink.js";
|
|
67
82
|
|
|
83
|
+
export { mediaSettle } from "./effects/media-settle.js";
|
|
84
|
+
export type { MediaSettleOptions } from "./effects/media-settle.js";
|
|
85
|
+
|
|
68
86
|
export { navHide } from "./effects/nav-hide.js";
|
|
69
87
|
export type { NavHideOptions } from "./effects/nav-hide.js";
|
|
70
88
|
|
|
@@ -75,9 +93,19 @@ export type { LogoRevealOptions } from "./effects/logo-reveal.js";
|
|
|
75
93
|
export { marquee } from "./effects/marquee.js";
|
|
76
94
|
export type { MarqueeOptions } from "./effects/marquee.js";
|
|
77
95
|
|
|
96
|
+
export { rollText } from "./effects/roll-text.js";
|
|
97
|
+
export type { RollTextOptions } from "./effects/roll-text.js";
|
|
98
|
+
|
|
78
99
|
export { dragStrip } from "./effects/drag-strip.js";
|
|
79
100
|
export type { DragStripOptions } from "./effects/drag-strip.js";
|
|
80
101
|
|
|
102
|
+
/* ---- text extras ---- */
|
|
103
|
+
export { scrambleText } from "./effects/scramble-text.js";
|
|
104
|
+
export type { ScrambleTextOptions } from "./effects/scramble-text.js";
|
|
105
|
+
|
|
106
|
+
export { flipWords } from "./effects/flip-words.js";
|
|
107
|
+
export type { FlipWordsOptions } from "./effects/flip-words.js";
|
|
108
|
+
|
|
81
109
|
/* ---- micro-interactions ---- */
|
|
82
110
|
export { liquidButton, underlineLink } from "./effects/liquid-button.js";
|
|
83
111
|
export type { LiquidButtonOptions } from "./effects/liquid-button.js";
|
|
@@ -85,6 +113,9 @@ export type { LiquidButtonOptions } from "./effects/liquid-button.js";
|
|
|
85
113
|
export { cursorFollower } from "./effects/cursor-follower.js";
|
|
86
114
|
export type { CursorFollowerOptions } from "./effects/cursor-follower.js";
|
|
87
115
|
|
|
116
|
+
export { magnetic } from "./effects/magnetic.js";
|
|
117
|
+
export type { MagneticOptions } from "./effects/magnetic.js";
|
|
118
|
+
|
|
88
119
|
export { counter, audioBars } from "./effects/counter.js";
|
|
89
120
|
export type { CounterOptions, AudioBarsOptions, AudioBarsHandle } from "./effects/counter.js";
|
|
90
121
|
|
package/src/styles/anim-kit.css
CHANGED
|
@@ -43,6 +43,13 @@
|
|
|
43
43
|
will-change: transform;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
/* Per-char masks produced by lineReveal({ split: "chars" }) / split(). */
|
|
47
|
+
.ak-char-mask {
|
|
48
|
+
display: inline-block;
|
|
49
|
+
overflow: clip;
|
|
50
|
+
vertical-align: bottom;
|
|
51
|
+
}
|
|
52
|
+
|
|
46
53
|
.ak-space {
|
|
47
54
|
display: inline-block;
|
|
48
55
|
white-space: pre;
|
|
@@ -197,6 +204,21 @@
|
|
|
197
204
|
background: linear-gradient(to left, var(--ak-background, #fff) 0%, transparent 100%);
|
|
198
205
|
}
|
|
199
206
|
|
|
207
|
+
/* ------------------------------------------------------------------ */
|
|
208
|
+
/* Rolling text (rollText) */
|
|
209
|
+
/* ------------------------------------------------------------------ */
|
|
210
|
+
|
|
211
|
+
/* The effect measures a row, then sets the box height + overflow inline so
|
|
212
|
+
teardown can restore authored styles exactly. This is the authored base. */
|
|
213
|
+
.ak-roll {
|
|
214
|
+
display: inline-block;
|
|
215
|
+
vertical-align: bottom;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
.ak-roll__inner {
|
|
219
|
+
will-change: transform;
|
|
220
|
+
}
|
|
221
|
+
|
|
200
222
|
/* ------------------------------------------------------------------ */
|
|
201
223
|
/* Drag strip */
|
|
202
224
|
/* ------------------------------------------------------------------ */
|