Add Vue/Nuxt examples and extends the frameworks Skill

- Adds a Vue folder in the examples, with a Vue demo using the Composition API
- Adds a Nuxt folder in the examples, that includes a re-usable composable for importing and registering all the GSAP Plugins at a top level file and lazy-load plugins that are not extensively used in the app
- Modifies the SKILL.MD file in the gsap-frameworks folder to reflect the previous addition
This commit is contained in:
Rodrigo Hernando committed 2026-04-08 18:22:22 -04:00
1 parent 03d9f0c3db
commit 63353bf7a2
12 files changed
+402 -5

No files matched your search

+3
View File
@@ -0,0 +1,3 @@
<template>
<NuxtPage />
</template>
@@ -0,0 +1,91 @@
import gsap from "gsap";
import { ScrollTrigger } from "gsap/ScrollTrigger";
const PLUGINS = [
"CSSRulePlugin",
"CustomBounce",
"CustomEase",
"CustomWiggle",
"Draggable",
"DrawSVGPlugin",
"EaselPlugin",
"EasePack",
"Flip",
"GSDevTools",
"InertiaPlugin",
"MorphSVGPlugin",
"MotionPathHelper",
"MotionPathPlugin",
"Observer",
"Physics2DPlugin",
"PhysicsPropsPlugin",
"PixiPlugin",
"ScrambleTextPlugin",
"ScrollSmoother",
"ScrollToPlugin",
"ScrollTrigger",
"SplitText",
"TextPlugin",
] as const;
type Plugins = typeof PLUGINS[number];
// In order to dynamically load all the GSAP plugins
const pluginMap = {
CustomEase: () => import("gsap/CustomEase"),
Draggable: () => import("gsap/Draggable"),
CSSRulePlugin: () => import("gsap/CSSRulePlugin"),
EaselPlugin: () => import("gsap/EaselPlugin"),
EasePack: () => import("gsap/EasePack"),
Flip: () => import("gsap/Flip"),
MotionPathPlugin: () => import("gsap/MotionPathPlugin"),
Observer: () => import("gsap/Observer"),
PixiPlugin: () => import("gsap/PixiPlugin"),
ScrollToPlugin: () => import("gsap/ScrollToPlugin"),
ScrollTrigger: () => import("gsap/ScrollTrigger"),
TextPlugin: () => import("gsap/TextPlugin"),
DrawSVGPlugin: () => import("gsap/DrawSVGPlugin"),
Physics2DPlugin: () => import("gsap/Physics2DPlugin"),
PhysicsPropsPlugin: () => import("gsap/PhysicsPropsPlugin"),
ScrambleTextPlugin: () => import("gsap/ScrambleTextPlugin"),
CustomBounce: () => import("gsap/CustomBounce"),
CustomWiggle: () => import("gsap/CustomWiggle"),
GSDevTools: () => import("gsap/GSDevTools"),
InertiaPlugin: () => import("gsap/InertiaPlugin"),
MorphSVGPlugin: () => import("gsap/MorphSVGPlugin"),
MotionPathHelper: () => import("gsap/MotionPathHelper"),
ScrollSmoother: () => import("gsap/ScrollSmoother"),
SplitText: () => import("gsap/SplitText"),
} as const;
type PluginMap = typeof pluginMap;
type Plugins = keyof PluginMap;
// Resolves the module type for a given key, then picks the named export matching the key
// this allows to have the type definitions for autocomplete in your code editor
type PluginModule<K extends Plugins> = Awaited<ReturnType<PluginMap[K]>>;
type PluginExport<K extends Plugins> = PluginModule<K>[K & keyof PluginModule<K>];
export default function() {
// Register all the GSAP Plugins you want at this point
gsap.registerPlugin(ScrollTrigger);
/*
If you want to lazy load some of the plugins that are
not widely used in your app (for example in just a couple
of components or a single route), you can use this method
*/
async function lazyLoadPlugin<K extends Plugins>(plugin: K): Promise<PluginExport<K>> {
const loader = pluginMap[plugin];
const m = await loader();
const p = (m as any)[plugin];
gsap.registerPlugin(p);
return p;
}
return {
gsap,
ScrollTrigger,
lazyLoadPlugin,
};
};
+56
View File
@@ -0,0 +1,56 @@
<script setup>
import { onMounted, onUnmounted } from "vue";
import useGSAP from "./composables/useGSAP.client";
const { gsap, ScrollTrigger, lazyLoadPlugin } = useGSAP();
let ctx;
onMounted(async () => {
const SplitText = await lazyLoadPlugin("SplitText");
ctx = gsap.context(() => {
const split = SplitText.create("h1", {
type: "chars",
});
gsap.from(split.chars, {
autoAlpha: 0,
y: -50,
xPercent: -100,
rotation: -45,
ease: "power1.inOut",
stagger: {
amount: 0.3,
},
});
gsap.set("h1", { autoAlpha: 1 });
});
});
onMounted(() => {
ctx && ctx.revert();
});
</script>
<template>
<main>
<h1>GSAP SplitText</h1>
</main>
</template>
<style scoped>
main {
width: 100%;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
font-size: 18px;
}
main h1 {
opacity: 0;
visibility: hidden;
}
</style>
+4
View File
@@ -0,0 +1,4 @@
export default defineNuxtConfig({
ssr: true,
compatibilityDate: '2025-07-15',
});
+18
View File
@@ -0,0 +1,18 @@
{
"name": "gsap-nuxt-example",
"type": "module",
"private": true,
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare"
},
"dependencies": {
"gsap": "^3.14.2",
"nuxt": "^4.4.2",
"vue": "^3.5.30",
"vue-router": "^5.0.4"
}
}