Keshav 75f95433e9 | 4 months ago | |
---|---|---|
README.md | 4 months ago |
Integrating GSAP with Webflow opens up a world of possibilities for stunning and creative animations. Here's a glimpse into what you can achieve with short and clean code examples:
1. Basic Scroll-Triggered Animation:
JavaScript
// Select element to animate
const element = document.querySelector('.animated-element');
// Define animation using GSAP TimelineLite
const animation = new TimelineLite({ paused: true });
animation.from(element, 1, { opacity: 0, y: 100 });
// Trigger animation on scroll
Webflow.require('ix2').triggerInview(element, () => {
animation.play();
});
2. Interactive Animations with Mouse Events:
JavaScript
// Select element and button
const element = document.querySelector('.interactive-element');
const button = document.querySelector('.trigger-button');
// Define animation using GSAP Tween
const animation = TweenLite.to(element, 1, { scale: 1.2, ease: Power2.easeInOut });
// Bind animation to button click
button.addEventListener('click', () => {
animation.play();
});
3. Complex Animations with GSAP Plugins:
JavaScript
// Include ScrollTrigger plugin
Webflow.require('gsap/ScrollTrigger');
// Define animation with ScrollTrigger plugin
const animation = TweenLite.fromTo(element, 1, { opacity: 0 }, { opacity: 1 }, {
scrollTrigger: {
trigger: element,
start: 'top bottom',
end: 'bottom top',
},
});
Want to build a custom webflow page?