nuxt-gsap-module v2.0.0
Features
- Helps you integrate
GSAPjavascript animation library - Allows you to easily animate elements via custom
v-gsapdirective π₯ - Provides a solution for global use via
this.$gsapπ€© - Automatically registers
pluginsafter activation - Allows you to easily register global
effects&eases - Supports
Club GreenSockpremium plugins π’ Zero-configsetup ready to go π
Quick Start
- Install
nuxt-gsap-moduledependency to your project
$ npm install --save-dev nuxt-gsap-module # or yarn add -D nuxt-gsap-module- Enable
nuxt-gsap-modulein thebuildModulessection
// nuxt.config.js
export default {
buildModules: ['nuxt-gsap-module'],
gsap: {
/* Module Options */
}
}That's it! Start developing your app!
Simple box rotation
// index.vue
export default {
mounted() {
this.boxRotation()
},
methods: {
boxRotation() {
const gsap = this.$gsap
gsap.to('.box', { rotation: 27, x: 100, duration: 1 })
}
}
}Nuxt global page transitions
// nuxt.config.js
export default {
buildModules: ['nuxt-gsap-module'],
// Add global page transition
pageTransition: {
name: 'page',
mode: 'out-in',
css: false,
beforeEnter(el) {
this.$gsap.set(el, {
opacity: 0
})
},
enter(el, done) {
this.$gsap.to(el, {
opacity: 1,
duration: 0.5,
ease: 'power2.inOut',
onComplete: done
})
},
leave(el, done) {
this.$gsap.to(el, {
opacity: 0,
duration: 0.5,
ease: 'power2.inOut',
onComplete: done
})
}
}
}Multiple plugins
After activation, plugins are automatically registered and available globally, so you wonβt have to worry about it (applies to all plugins).
// nuxt.config.js
export default {
gsap: {
extraPlugins: {
scrollTo: true,
scrollTrigger: true
},
extraEases: {
expoScaleEase: true
}
}
}// Usage
export default {
mounted() {
this.animateOnScroll()
},
methods: {
animateOnScroll() {
this.$gsap.to(window, { duration: 2, scrollTo: 1000 })
this.$gsap.to('.box', {
x: 500,
ease: 'Power1.easeInOut',
scrollTrigger: {
trigger: '.content',
pin: true,
end: 'bottom',
scrub: true
}
})
}
}
}Custom Modifiers
Module allows you to easily animate elements via custom v-gsap directive and its modifiers.
gsap.set()
- Modifier:
v-gsap.set - Default:
true
<template>
<p v-gsap.set="{ x: 100, y: 50 }">NUXT GSAP</p>
</template>gsap.to()
- Modifier:
v-gsap.to - Default:
true
<template>
<h1
v-gsap.to="{
rotation: 360,
x: 150,
duration: 2
}"
>
NUXT GSAP
</h1>
</template>gsap.from()
- Modifier:
v-gsap.from - Default:
true
<template>
<span
v-gsap.from="{
opacity: 0,
x: -200,
duration: 1
}"
>
NUXT GSAP
</span>
</template>gsap.fromTo()
- Modifier:
v-gsap.fromTo - Default:
true
<template>
<p
v-gsap.fromTo="[
{ opacity: 0, y: -350 },
{ opacity: 1, y: 0, duration: 3 }
]"
>
NUXT GSAP
</p>
</template>Module Options
Here are all the default options that can be used for customization:
// nuxt.config.js
export default {
gsap: {
extraPlugins: {},
extraEases: {},
clubPlugins: {},
registerEffect: [],
registerEase: []
}
}GSAP's core
$gsap
- Default:
true
GSAP's core is enabled by default so there is no need for additional configuration.
// nuxt.config.js
export default {
buildModules: ['nuxt-gsap-module']
}Available globally
// Access GSAP by using
this.$gsap
// or
const gsap = this.$gsap
gsap.to('.box', { rotation: 27, x: 100, duration: 1 })Register Effect
- Default:
[]
This option allows you to easily register a global effect. Once the effect is registered, it can be accessed directly on the gsap.effects object.
// nuxt.config.js
export default {
gsap: {
registerEffect: [
{
name: 'fadeIn',
effect: (targets, config) => {
// ...
}
},
{
name: 'fadeOut',
effect: (targets, config) => {
// ...
}
},
{
name: 'fadeInOut',
effect: (targets, config) => {
// ...
}
}
]
}
}// Effects can be accessed as follows
this.$gsap.effects.fadeIn('.class')
this.$gsap.effects.fadeOut('#id')
this.$gsap.effects.fadeInOut(element)
// or
const gsap = this.$gsap
gsap.effects.fadeIn('.class')
gsap.effects.fadeOut('#id')
gsap.effects.fadeInOut(element)
// or directly on timelines
let tl = this.$gsap.timeline()
tl.fadeIn('.class', { duration: 3 })
.fadeIn('#id', { duration: 1 }, '+=2')
.to('.class2', { x: 100 })Register Ease
- Default:
[]
This option allows you to easily register a global ease.
// nuxt.config.js
export default {
gsap: {
registerEase: [
{
name: 'myEase',
ease: progress => {
return progress // linear
}
},
{
name: 'ease.2',
ease: progress => {
// ...
}
},
{
name: 'customEase.3',
ease: progress => {
// ...
}
}
]
}
}<!-- index.vue -->
<template>
<div>
<h1 to="/about" class="title">Custom Title</h1>
<p class="text">Custom text...</p>
</div>
</template>
<script>
export default {
mounted() {
this.$gsap.to('.title', { x: 100, ease: 'myEase' })
this.$gsap.to('.text', { y: 100, ease: 'ease.2' })
}
}
</script>Extra Plugins
Flip
- Default:
false - Moved to public downloads (
>=v1.6)
// nuxt.config.js
export default {
gsap: {
extraPlugins: {
flip: true
}
}
}// Access the plugin by using
this.$FlipScrollTrigger
- Default:
false
// nuxt.config.js
export default {
gsap: {
extraPlugins: {
scrollTrigger: true
}
}
}// Access the plugin by using
this.$ScrollTriggerObserver
- Default:
false
// nuxt.config.js
export default {
gsap: {
extraPlugins: {
observer: true
}
}
}// Access the plugin by using
this.$ObserverScrollToPlugin
- Default:
false
// nuxt.config.js
export default {
gsap: {
extraPlugins: {
scrollTo: true
}
}
}// Access the plugin by using
this.$ScrollToPluginDraggable
- Default:
false
// nuxt.config.js
export default {
gsap: {
extraPlugins: {
draggable: true
}
}
}// Access the plugin by using
this.$DraggableEaselPlugin
- Default:
false
// nuxt.config.js
export default {
gsap: {
extraPlugins: {
easel: true
}
}
}// Access the plugin by using
this.$EaselPluginMotionPathPlugin
- Default:
false
// nuxt.config.js
export default {
gsap: {
extraPlugins: {
motionPath: true
}
}
}// Access the plugin by using
this.$MotionPathPluginPixiPlugin
- Default:
false
// nuxt.config.js
export default {
gsap: {
extraPlugins: {
pixi: true
}
}
}// Access the plugin by using
this.$PixiPluginTextPlugin
- Default:
false
// nuxt.config.js
export default {
gsap: {
extraPlugins: {
text: true
}
}
}// Access the plugin by using
this.$TextPluginCSSRulePlugin
- Deprecated (
>=v1.6)
CSSRulePlugin has been deprecated in favor of using CSS variables which have excellent browser support these days.
GSAP has native support for animating CSS variables, like:
this.$gsap.to('html', { '--my-variable': 100, duration: 2 })Extra Eases
ExpoScaleEase
- Default:
false
// nuxt.config.js
export default {
gsap: {
extraEases: {
expoScaleEase: true
}
}
}// Access the plugin by using
this.$ExpoScaleEaseRoughEase
- Default:
false
// nuxt.config.js
export default {
gsap: {
extraEases: {
roughEase: true
}
}
}// Access the plugin by using
this.$RoughEaseSlowMo
- Default:
false
// nuxt.config.js
export default {
gsap: {
extraEases: {
slowMo: true
}
}
}// Access the plugin by using
this.$SlowMoCustomEase
- Default:
false - Moved to public downloads (
>=v1.6)
// nuxt.config.js
export default {
gsap: {
extraEases: {
customEase: true
}
}
}// Access the plugin by using
this.$CustomEaseClub GreenSock Plugins
nuxt-gsap-module supports Club GreenSock premium plugins. They can be easily activated via module settings, just like the free ones.
Installation
- Follow the official instructions and install the
premiumplugins as usual. - After installation, simply activate the desired plugins and that's it, you're ready to go!
DrawSVGPlugin
- Default:
false
// nuxt.config.js
export default {
gsap: {
clubPlugins: {
drawSVG: true
}
}
}// Access the plugin by using
this.$DrawSVGPluginScrollSmoother
- Default:
false
// nuxt.config.js
export default {
gsap: {
clubPlugins: {
scrollSmoother: true
}
}
}// Access the plugin by using
this.$ScrollSmootherGSDevTools
- Default:
false
// nuxt.config.js
export default {
gsap: {
clubPlugins: {
gsDevTools: true
}
}
}// Access the plugin by using
this.$GSDevToolsInertiaPlugin
- Default:
false
// nuxt.config.js
export default {
gsap: {
clubPlugins: {
inertia: true
}
}
}// Access the plugin by using
this.$InertiaPluginMorphSVGPlugin
- Default:
false
// nuxt.config.js
export default {
gsap: {
clubPlugins: {
morphSVG: true
}
}
}// Access the plugin by using
this.$MorphSVGPluginMotionPathHelper
- Default:
false
// nuxt.config.js
export default {
gsap: {
clubPlugins: {
motionPathHelper: true
}
}
}// Access the plugin by using
this.$MotionPathHelperPhysics2DPlugin
- Default:
false
// nuxt.config.js
{
gsap: {
clubPlugins: {
physics2D: true
}
}
}// Access the plugin by using
this.$Physics2DPluginPhysicsPropsPlugin
- Default:
false
// nuxt.config.js
export default {
gsap: {
clubPlugins: {
physicsProps: true
}
}
}// Access the plugin by using
this.$PhysicsPropsPluginScrambleTextPlugin
- Default:
false
// nuxt.config.js
export default {
gsap: {
clubPlugins: {
scrambleText: true
}
}
}// Access the plugin by using
this.$ScrambleTextPluginSplitText
- Default:
false
// nuxt.config.js
export default {
gsap: {
clubPlugins: {
splitText: true
}
}
}// Access the plugin by using
this.$SplitTextCustomBounce
- Default:
false
// nuxt.config.js
export default {
gsap: {
clubPlugins: {
customBounce: true
}
}
}// Access the plugin by using
this.$CustomBounceCustomWiggle
- Default:
false
// nuxt.config.js
export default {
gsap: {
clubPlugins: {
customWiggle: true
}
}
}// Access the plugin by using
this.$CustomWiggleLicense
GSAP
Copyright (c) GreenSock
Nuxt GSAP module
Copyright (c) Ivo Dolenc
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago