Instructions
This interaction adds a dynamic mouse trail animation to your Webflow site. When the user moves the cursor inside a section, an image smoothly appears at the cursor position, scales up, and fades away as it moves downward — creating a cinematic visual flow powered by GSAP.
GSAP Mouse Trail Animation — Instructions
🧩 Structure Overview:
To make this interaction work, your layout must include the following classes:
| Element | Class Name | Description |
| -------------- | ------------------ | ------------------------------------------------------------- |
| Main wrapper | `.gsap-component` | The container that holds the entire GSAP interaction |
| Visual wrapper | `.gsap-wrapper` | The container where the animated images will appear |
| Image element | `.gsap-image-wrap` | The element that contains the image being cloned and animated |
⚠️ Make sure the class names match exactly (all lowercase, separated by hyphens).
⚙️ How the Animation Works:
- The script looks for every
.gsap-componenton the page. - It tracks the mouse movement inside that area.
- Each time the cursor moves more than 100px, the animation triggers.
- The
.gsap-image-wrapelement is cloned and positioned at the cursor location. - Using GSAP, the cloned image fades in, scales up, and then fades out while moving downward.
- Once the animation finishes, the image clone is automatically removed from the DOM — keeping performance smooth.
This creates a floating image trail that follows the user’s cursor with an elegant, minimal animation.
🧠 Customization Guide:
1. Adjust the Trigger Distance
To control how often the animation activates, locate this line:
if (Math.abs(xPosition - e.pageX) > 100 || Math.abs(yPosition - e.pageY) > 100)
Change the 100 value to:
- Smaller value (e.g.,
60) → animation triggers more frequently - Larger value (e.g.,
150) → animation triggers less frequently
2. Modify the Entry Animation
This part controls how the image appears:
tl.fromTo(imageWrap,
{ opacity: 0, scale: 0.5 },
{ opacity: 1, scale: 1, ease: "power3.out" }
);
You can adjust:opacity: how visible the image startsscale: the zoom amount when it appearsease: the smoothness of the motion (try"expo.out"or"back.out(1.7)")
3. Edit the Exit Animation
This line defines how the image disappears:
tl.to(imageWrap.find("img"), { opacity: 0, y: "8rem", duration: 0.5 });
opacity: controls fade-out strengthy: defines the vertical movement — use negative values (e.g.,"-8rem") to make it move upwardduration: how long the animation lasts (increase for slower motion)
4. Change the Animation Direction
If you prefer a horizontal or diagonal motion, you can add or replace movement properties:
tl.to(imageWrap.find("img"), { opacity: 0, x: "6rem", y: "6rem", duration: 0.6 });
This will make the image move diagonally as it fades out.
5. Use Different Images
If you want to use different visuals, simply replace the image inside .gsap-image-wrap in your Webflow Designer.
You can duplicate this element or change the image source manually — no CMS setup is required.
💡 Pro Tips
- ou can duplicate the
.gsap-componentsection to use the effect in multiple parts of your site. - Always keep the GSAP library
<script>tag above the interaction script. - For best performance, keep your image file sizes optimized.
- Test the interaction on different screen sizes to ensure smooth behavior.
