Modifiers
Discover all the different features of v-gsap.
.from, .to, .fromTo, .call
V-GSAP supports the above four main animation types.
.fromanimates from a given state to its current state.toanimates from the current state to a given to-state.fromTocombines both the above. It takes an Array of two states as value.calltakes an arrow function as value and executes it- when used with
.whenVisible., it will automatically be handled like.once.
- when used with
.whenVisible
- enables scrollTrigger. It defaults to from
top 90%totop 50%andscrub - you can overwrite these properties in the value Object. In combination with
.fromTo, put the overrides in the second state
.fromInvisible
- Adds
opacity: 0as initial state and includesopacity: 1in.toor.fromTo. - This prevents the element from being visible until the directive takes action. Especially needed for above-the-fold animations
- With this modifier you can create entrance animations without always repeating the opacity hassle.
.once
Makes the animation play only once when scrolling down, and stay in its final state even when scrolling back up.
.once.reversible
Similar to .once but will reverse the animation when scrolling back up, allowing it to play again when scrolling down.
.once..markers
Adds markers for debugging.
Custom Scroller
If your content is wrapped in an artificial scroll container, use { [...], scroller: '<selector>' } as a selector string inside the value object to override the default scroll container.
nuxt.config.tsSee details.parallax
- enables parallax effect for this element. Brings its own scrollTrigger, therefore doesn't need extra
.whenVisible.. - Only works with a speed settings like:
.slower-<integer>
.faster-<integer>
Element scrolls slower or faster than the default scroll speed.
- The value is a multiplier of 10% element height. E.g.
.slower-5scrolls the element from +-50% to +-50% height. - If the value is left out, default is
5. Meaning:.slowerdefaults to.slower-5(same with faster)
.stagger
enables stagger for immediate children if placed on the parent. Duration can be overwritten in the value object.
.infinitely
This sets the repeat of the timeline to -1 to infinitely repeat the animation
.delay-<milliseconds>
- can be added to delay the action for n milliseconds like
.delay-500. - any integer value will be accepted, like
.delay-1234.
Note: Only works with whenVisible if used with once
.whileHover
lets you define a hover animation. By default, it reverses on leave.
.noReverse
can be used to disable the reversing on leave
.draggable
Allows the element to be draggable
.x, .y, .rotation
allows to restrict the direction of the drag.
.bounds
restricts the container.
- If left empty (
.draggable.bounds) it restricts the parent. - A querySelector can be passed
v-gsap.draggable.bounds="'.someContainer'"
.animateText.
Animates Text letter by letter
- It can either take a string as value like
v-gsap.animateText="'Das ist ein Text'"
- Or if no value is given, it takes the inner textContent from the element
<div v-gsap.animateText> Inner Text </div>
.slow, .fast
Changes the typing speed
.magnetic
Makes an element be magnetically attracted to the cursor
.weak, .weaker, .stronger, .strong
Modifies the strength of attraction.
.refuse
Will make the element try to flee from the cursor
.mobile
.desktop
With these you can specify the viewport on which the animation shall take place.
- Window resizing is handled automatically.
- Breakpoint is
768px - You can combine both. Simply use both
v-gsap.mobile.ANDv-gsap.desktop.on the same element.
.preset
You can define presets in nuxt.config.ts to make animations reusable.
.entrance
This is similar to .preset, but focuses on predefined entrance animations.
There are the following options out of the box:
.slide-left- Slides and fades in from left
.slide-right- Slides and fades in from right
.slide-top- Slides and fades in from top
.slide-bottom- Slides and fades in from bottom
.fade- Simply fades in
.scale- Fades and scales in from 75% size
.scale-full- Fades and scales in from 0% size
.entrance uses .whenVisible.once under the hood..once is needed to ensure animations run through even if scrollTrigger start is passed (e.g. in a hero section)