gclass-anims 1.0.0-beta.2 → 1.0.0-beta.21
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/AnimToggle.js +199 -7
- package/Animations.js +324 -31
- package/CHANGELOG.md +53 -0
- package/Config.js +43 -5
- package/LICENSE +2 -2
- package/Listeners.js +450 -95
- package/README.md +4 -4
- package/index.d.ts +73 -4
- package/index.js +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ Framework-agnostic: works in vanilla JS, React, Vue, Svelte, or any bundler.
|
|
|
6
6
|
|
|
7
7
|
## Live demo
|
|
8
8
|
|
|
9
|
-
https://saturn-sepehr.github.io/GClass/
|
|
9
|
+
https://saturn-sepehr.github.io/GClass/
|
|
10
10
|
|
|
11
11
|
## Installation
|
|
12
12
|
|
|
@@ -62,7 +62,7 @@ export default {
|
|
|
62
62
|
|
|
63
63
|
## Usage
|
|
64
64
|
|
|
65
|
-
Add utility classes to your markup. Everything is class-driven
|
|
65
|
+
Add utility classes to your markup. Everything is class-driven - no config.
|
|
66
66
|
|
|
67
67
|
```html
|
|
68
68
|
<div class="spawn-up">reveals sliding up on scroll</div>
|
|
@@ -98,5 +98,5 @@ customAnims.push({
|
|
|
98
98
|
|
|
99
99
|
## License
|
|
100
100
|
|
|
101
|
-
MIT
|
|
102
|
-
License and is not bundled or redistributed.
|
|
101
|
+
MIT - except GSAP, which is used under the Webflow Standard No-Charge GSAP
|
|
102
|
+
License and is not bundled or redistributed. See `LICENSE`.
|
package/index.d.ts
CHANGED
|
@@ -4,8 +4,28 @@
|
|
|
4
4
|
|
|
5
5
|
// --- AnimToggle ------------------------------------------------------------
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
export interface GClassConfig {
|
|
8
|
+
throttlePerFrame: number
|
|
9
|
+
fps: number
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Boots the GSAP animation system (idempotent).
|
|
14
|
+
* @param throttlePerFrame - number of observer handlers allowed per rAF frame (0 = no throttling, default).
|
|
15
|
+
* Also accepts initAnimations({throttlePerFrame, fps}) object overload.
|
|
16
|
+
* @param fps - GSAP ticker fps cap (0 = default rAF, e.g. 30 for low-end). 0/undefined = no cap.
|
|
17
|
+
*/
|
|
18
|
+
export function initAnimations(throttlePerFrame?: number | GClassConfig, fps?: number): void
|
|
19
|
+
/**
|
|
20
|
+
* Change GClass runtime options on the fly without reload.
|
|
21
|
+
* gclassOpts(throttlePerFrame, fps) — both optional numbers, missing -> defaults (0).
|
|
22
|
+
* gclassOpts() resets to defaults (no throttle, default ticker).
|
|
23
|
+
* Also accepts gclassOpts({throttlePerFrame, fps}).
|
|
24
|
+
* Example low-end button: onClick={() => gclassOpts(1, 30)}
|
|
25
|
+
*/
|
|
26
|
+
export function gclassOpts(throttlePerFrame?: number | GClassConfig, fps?: number): GClassConfig
|
|
27
|
+
export function getGClassConfig(): GClassConfig
|
|
28
|
+
export function subscribeGClassConfig(cb: (cfg: GClassConfig) => void): () => void
|
|
9
29
|
/** Toggle animations on/off and reload the page. */
|
|
10
30
|
export function toggleAnimations(): void
|
|
11
31
|
/** Force animations off (wins over any stored preference) and reload. */
|
|
@@ -27,8 +47,13 @@ export function registerComplete(name: string, fn: CompleteHandler): CompleteHan
|
|
|
27
47
|
/**
|
|
28
48
|
* Boot the engine directly, bypassing AnimToggle. Returns a teardown function
|
|
29
49
|
* that removes all listeners/observers/tweens created by this run.
|
|
50
|
+
* Pass a root to scope to that subtree (used for .boot-up).
|
|
51
|
+
* @param root - scope root (Document or HTMLElement)
|
|
52
|
+
* @param throttlePerFrame - number of observer handlers allowed per rAF frame.
|
|
53
|
+
* 0/undefined = no throttling (default). 1 = 1 observer per frame round-robin.
|
|
54
|
+
* Overload: initListeners(throttlePerFrame) is also supported (root defaults to document).
|
|
30
55
|
*/
|
|
31
|
-
export default function initListeners(): () => void
|
|
56
|
+
export default function initListeners(root?: Document | HTMLElement | number, throttlePerFrame?: number): () => void
|
|
32
57
|
|
|
33
58
|
// --- onComplete config -----------------------------------------------------
|
|
34
59
|
|
|
@@ -64,6 +89,10 @@ export interface AnimationConfig {
|
|
|
64
89
|
typewriter?: boolean
|
|
65
90
|
/** Marks a per-part (SplitText) typewriter entry. */
|
|
66
91
|
typewriterSplit?: boolean
|
|
92
|
+
/** Marks a numeric counter entry (counts from `.spawn-num-N` to the element's number). */
|
|
93
|
+
count?: boolean
|
|
94
|
+
/** Marks a ScrambleText entry (text resolves out of garbage characters). */
|
|
95
|
+
scramble?: boolean
|
|
67
96
|
/** Set false to skip generating a `.spawn-text-<name>` variant. Default true. */
|
|
68
97
|
text?: boolean
|
|
69
98
|
/** Set false to keep `build` but skip the always-on repeat. Default true. */
|
|
@@ -79,6 +108,8 @@ export interface SpawnConfig {
|
|
|
79
108
|
play: (el: HTMLElement, delay: number, dur: number, ease: string) => any
|
|
80
109
|
typewriter?: boolean
|
|
81
110
|
typewriterSplit?: boolean
|
|
111
|
+
count?: boolean
|
|
112
|
+
scramble?: boolean
|
|
82
113
|
text: boolean
|
|
83
114
|
}
|
|
84
115
|
|
|
@@ -115,6 +146,9 @@ export interface Defaults {
|
|
|
115
146
|
textStagger: number
|
|
116
147
|
typewriterSplitCharDuration: number
|
|
117
148
|
minTextPartDuration: number
|
|
149
|
+
revealDelay: number
|
|
150
|
+
characterlist: string
|
|
151
|
+
bootTime: number
|
|
118
152
|
}
|
|
119
153
|
|
|
120
154
|
/** Global timing / ease defaults (edit to tweak global behaviour). */
|
|
@@ -162,6 +196,40 @@ export function expandDown(target: TweenTarget, delay: number, dur: number, ease
|
|
|
162
196
|
export function countUp(target: TweenTarget, delay: number, dur: number, ease: string): any
|
|
163
197
|
/** Reads a count element's start (`.spawn-num-N`, else 0), target number, and decimals. */
|
|
164
198
|
export function countTargetVars(target: TweenTarget): { start: number; end: number; decimals: number }
|
|
199
|
+
/**
|
|
200
|
+
* Reads a scramble element's modifiers against the package defaults:
|
|
201
|
+
* `.amount-N` -> speed (default 1), `.reveal-delay-N` -> revealDelay
|
|
202
|
+
* (default `defaults.revealDelay`), `.chars-[...]` -> character pool verbatim
|
|
203
|
+
* (default `defaults.characterlist`). Also segments the element: only
|
|
204
|
+
* top-level text runs are scrambled (each wrapped in its own span); nested
|
|
205
|
+
* elements are preserved untouched.
|
|
206
|
+
*/
|
|
207
|
+
export function scrambleVars(target: TweenTarget): {
|
|
208
|
+
segs: { t: any; text: string }[]
|
|
209
|
+
chars: string
|
|
210
|
+
speed: number
|
|
211
|
+
revealDelay: number
|
|
212
|
+
rtl: boolean
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Scramble spawn: the text starts empty and resolves into its real content
|
|
216
|
+
* through garbage characters (ScrambleTextPlugin). No opacity change; nested
|
|
217
|
+
* elements are preserved. Defaults to a linear ease so `.time-N` is the true
|
|
218
|
+
* total reveal time - an explicit `.ease-*` class overrides. Modifiers read
|
|
219
|
+
* from the element: .reveal-delay-N, .chars-[...], .amount-N, .scramble-all
|
|
220
|
+
* (whole-string scramble-and-sweep, no empty-start typing), .scramble-rtl.
|
|
221
|
+
*/
|
|
222
|
+
export function scramble(target: TweenTarget, delay: number, dur: number, ease: string): any
|
|
223
|
+
/** Progressively draws the target's SVG stroke from 0% to 100% (strokes only). */
|
|
224
|
+
export function drawsvg(target: TweenTarget, delay: number, dur: number, ease: string): any
|
|
225
|
+
/**
|
|
226
|
+
* Splits multi-segment `<path>` elements (multiple "M" commands) into one
|
|
227
|
+
* single-segment `<path>` per segment. Destructive: source paths are replaced.
|
|
228
|
+
* Results are cached on the original element for engine re-inits.
|
|
229
|
+
*/
|
|
230
|
+
export function splitPaths(paths: any): any[]
|
|
231
|
+
/** DrawSVG variant that splits multi-segment paths first, then draws each segment sequentially at constant speed. Returns a timeline. */
|
|
232
|
+
export function drawsvgSplit(target: TweenTarget, delay: number, dur: number, ease: string): any
|
|
165
233
|
export function verticalmove(target: TweenTarget, amount: number, dur: number, ease: string): any
|
|
166
234
|
export function expandmove(target: TweenTarget, amount: number, dur: number, ease: string): any
|
|
167
235
|
export function magnet(target: TweenTarget, x: number, y: number, scale: number, dur: number, ease: string): any
|
|
@@ -177,4 +245,5 @@ export function radiate(delay: number, target: TweenTarget, amount: number, dur:
|
|
|
177
245
|
export function hover(delay: number, target: TweenTarget, amount: number, dur: number, ease: string): any
|
|
178
246
|
export function marquee(target: TweenTarget, dir: string, duration: number, xOffset?: number, yOffset?: number, noRepeat?: boolean): any
|
|
179
247
|
export function flip(state: any, ease: string, dur: number): any
|
|
180
|
-
export function animatecss(target: TweenTarget, dur: number, delay: number, ease: string, propertyS: any, propertySValue: any, propertyE: any, propertyEValue: any): any
|
|
248
|
+
export function animatecss(target: TweenTarget, dur: number, delay: number, ease: string, propertyS: any, propertySValue: any, propertyE: any, propertyEValue: any): any
|
|
249
|
+
|
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { initAnimations, toggleAnimations, enableReducedMotion, disableReducedMotion } from './AnimToggle.js'
|
|
1
|
+
export { initAnimations, gclassOpts, getGClassConfig, subscribeGClassConfig, toggleAnimations, enableReducedMotion, disableReducedMotion } from './AnimToggle.js'
|
|
2
2
|
export { default as initListeners, registerComplete } from './Listeners.js'
|
|
3
3
|
export { customAnims } from './CustomAnims.js'
|
|
4
4
|
export { defaults, animations, normalize } from './Config.js'
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gclass-anims",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
4
|
-
"description": "A Tailwind-style utility layer on top of GSAP. Framework-agnostic
|
|
3
|
+
"version": "1.0.0-beta.21",
|
|
4
|
+
"description": "A Tailwind-style utility layer on top of GSAP. Framework-agnostic - works in vanilla JS, React, Vue, Svelte, or any bundler.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"module": "index.js",
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
"Config.js",
|
|
23
23
|
"CustomAnims.js",
|
|
24
24
|
"README.md",
|
|
25
|
-
"LICENSE"
|
|
25
|
+
"LICENSE",
|
|
26
|
+
"CHANGELOG.md"
|
|
26
27
|
],
|
|
27
28
|
"keywords": [
|
|
28
29
|
"gsap",
|
|
@@ -39,9 +40,8 @@
|
|
|
39
40
|
"url": "git+https://github.com/Saturn-sepehr/GClass.git",
|
|
40
41
|
"directory": "/"
|
|
41
42
|
},
|
|
42
|
-
"homepage": "https://saturn-sepehr.github.io/GClass/
|
|
43
|
+
"homepage": "https://saturn-sepehr.github.io/GClass/",
|
|
43
44
|
"dependencies": {
|
|
44
|
-
"gclass-anims": "^1.0.0-beta.1",
|
|
45
45
|
"gsap": "^3.15.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependenciesMeta": {},
|