A class-driven GSAP animation wrapper for WordPress and static sites. Add a CSS class to any element and it animates — no JavaScript needed per page.
npm installLoad GSAP + plugins + FX as separate script tags — no build step needed:
<!-- 1. GSAP core -->
<script src="node_modules/gsap/dist/gsap.min.js"></script>
<!-- 2. GSAP plugins -->
<script src="node_modules/gsap/dist/ScrollTrigger.min.js"></script>
<script src="node_modules/gsap/dist/SplitText.min.js"></script>
<!-- 3. Fancoolo FX -->
<script src="src/fx.js"></script>Then add classes in your HTML. Done. FX auto-initializes on DOMContentLoaded.
<h1 class="fx-text-reveal-pl">Hello World</h1>The heading animates with a masked line-reveal on page load.
| Effect | Page Load | Scroll Trigger | Description |
|---|---|---|---|
| Text Reveal | .fx-text-reveal-pl |
.fx-text-reveal-st |
Split lines, mask, slide up |
| Reveal | .fx-reveal-pl |
.fx-reveal-st |
Slide up + fade |
| Spin Reveal | .fx-spin-reveal-pl |
.fx-spin-reveal-st |
Rotate + scale in |
| BG Reveal | .fx-bg-reveal-pl |
.fx-bg-reveal-st |
Background slide up |
| Scale In | .fx-scale-in-pl |
.fx-scale-in-st |
Scale up + fade |
Three trigger modes:
-pl— Page load: animates when the DOM is ready-st— Scroll trigger: animates when the element enters the viewport- No suffix — Section trigger: bare
.fx-text-revealinside a<section>is auto scroll-triggered using the section as the trigger
When FX sees a scroll-triggered element (-st suffix or bare class inside a section), it creates a GSAP ScrollTrigger with these defaults:
start: 'top 85%'— the animation fires when the top of the element (or its section) reaches 85% down from the top of the viewportonce: true— plays once, doesn't replay on re-scroll
For grouped siblings (same class, same parent), the parent is used as the shared trigger — so all items animate together with stagger, rather than each triggering independently.
Elements with bare .fx-* classes (no -pl/-st suffix) inside a <section> are automatically scroll-triggered using the section as the trigger:
<section>
<h2 class="fx-text-reveal">This auto-triggers on scroll</h2>
<p class="fx-text-reveal">No suffix needed inside a section</p>
<img src="photo.jpg" class="fx-reveal" />
</section>Change the container selector via config:
FX.config.sectionSelector = '.animate-section'; // only sections with this class
FX.config.sectionSelector = 'section, .wp-block-group'; // multiple selectorsFor zero-class animation, configure tagMap to automatically animate elements by their tag name inside sections:
<!-- Set config BEFORE the FX script loads -->
<script>
window.__FX_CONFIG__ = {
tagMap: {
'h1,h2,h3,h4,h5,h6': 'textReveal',
'p,blockquote': 'textReveal',
'img,video': 'reveal',
}
};
</script>
<script src="dist/fx.min.js"></script>Or configure after load and re-init:
FX.config.tagMap = { 'h1,h2,h3': 'textReveal', 'img': 'reveal' };
FX.init();Elements already animated by explicit .fx-* classes are skipped — tagMap only picks up unhandled elements.
Sibling elements with the same class are automatically staggered (0.15s between each):
<div>
<p class="fx-text-reveal-st">First paragraph</p>
<p class="fx-text-reveal-st">Second paragraph</p>
<p class="fx-text-reveal-st">Third paragraph</p>
</div>Override timing per-element using modifier classes (Gutenberg-friendly — no inline styles needed):
| Class | Default | Description |
|---|---|---|
fx-duration-[n] |
1.2 (text) / 1 (others) |
Animation duration in seconds |
fx-delay-[n] |
0 |
Start delay in seconds |
fx-stagger-[n] |
0.1 |
Delay between staggered items |
fx-ease-[name] |
power3.out |
GSAP easing function |
<h2 class="fx-text-reveal-st fx-duration-[2] fx-stagger-[0.25]">
Slower and wider stagger
</h2>Add these in Gutenberg via the "Additional CSS class(es)" field alongside the effect class.
For compound sequences or dynamic content, use the FX global:
FX.textReveal(document.querySelector('.hero-title'), {
trigger: 'scroll',
delay: 0.3,
scrollTrigger: { trigger: '.hero-section' }
});All functions accept (element, options):
| Function | Options |
|---|---|
textReveal(el, opts) |
duration, ease, stagger, delay, trigger, scrollTrigger |
reveal(el, opts) |
y (default 80), duration, ease, delay, trigger, scrollTrigger |
spinReveal(el, opts) |
rotation (default -30), scale (default 0.9), duration, ease, delay, trigger, scrollTrigger |
bgReveal(el, opts) |
duration, ease, delay, trigger, scrollTrigger |
scaleIn(el, opts) |
scale (default 0.92), duration, ease, delay, trigger, scrollTrigger |
Set trigger: 'scroll' to enable ScrollTrigger. Pass scrollTrigger: { trigger: someEl } to use a different trigger element.
- Copy this repo (or
npm install) - Add the 4 script tags (gsap, ScrollTrigger, SplitText, fx.js)
- Add
.fx-*classes in your HTML
For compound sequences, create a project-specific JS file loaded after fx.js:
// animations.js — loaded after fx.js
document.addEventListener('DOMContentLoaded', function () {
var hero = document.querySelector('.hero');
if (hero) {
FX.scaleIn(hero.querySelector('.card'), { trigger: 'scroll', scrollTrigger: { trigger: hero } });
FX.textReveal(hero.querySelector('h2'), { trigger: 'scroll', delay: 0.2, scrollTrigger: { trigger: hero } });
}
});├── fancoolo-fx.php ← WordPress plugin
├── readme.txt ← WP plugin readme
├── assets/ ← GSAP + fx.js copies for WP
├── src/fx.js ← Source of truth (npm package entry)
├── package.json ← npm deps (gsap)
├── docs/ ← GitHub Pages site
├── .distignore ← Files excluded from WP plugin zip
├── .npmignore ← Files excluded from npm package
├── CLAUDE.md ← Project context for Claude
└── README.md
Fancoolo FX uses CSS classes which you can add via the "Additional CSS class(es)" field in the block sidebar. No data attributes or inline styles needed.
Use WP-CLI dist-archive to build a clean plugin zip. The .distignore file controls which files are excluded.
# Install the command (one-time)
wp package install wp-cli/dist-archive-command
# Build the zip from the project root
wp dist-archive .This produces fancoolo-fx.1.x.x.zip containing only the plugin files (fancoolo-fx.php, readme.txt, assets/). Upload it via Plugins → Add New → Upload in WordPress.
# Set token once (stored in ~/.npmrc)
npm config set //registry.npmjs.org/:_authToken=YOUR_TOKEN
# Publish from the project root
npm publishOnly src/fx.js, package.json, and README.md are published (controlled by .npmignore).
- Bump version in
package.jsonandfancoolo-fx.php - Run
npm run syncto copysrc/fx.jstoassets/anddocs/vendor/ - Commit and push to main
- Tag and push:
git tag X.Y.Z && git push origin X.Y.Z(triggers GitHub Release with plugin zip) - Publish to npm:
npm publish