No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

hace 5 meses
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # GSAP advance integration in webflow
  2. 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:
  3. **1. Basic Scroll-Triggered Animation:**
  4. - Use Webflow's scroll trigger on a div.
  5. - In the "Actions" tab, add a "Run JavaScript" action and paste the following code:
  6. ```
  7. JavaScript
  8. // Select element to animate
  9. const element = document.querySelector('.animated-element');
  10. // Define animation using GSAP TimelineLite
  11. const animation = new TimelineLite({ paused: true });
  12. animation.from(element, 1, { opacity: 0, y: 100 });
  13. // Trigger animation on scroll
  14. Webflow.require('ix2').triggerInview(element, () => {
  15. animation.play();
  16. });
  17. ```
  18. **2. Interactive Animations with Mouse Events:**
  19. - Bind GSAP animations to hover or click events on elements using JavaScript.
  20. - This creates dynamic and engaging interactions for your Webflow website.
  21. ```
  22. JavaScript
  23. // Select element and button
  24. const element = document.querySelector('.interactive-element');
  25. const button = document.querySelector('.trigger-button');
  26. // Define animation using GSAP Tween
  27. const animation = TweenLite.to(element, 1, { scale: 1.2, ease: Power2.easeInOut });
  28. // Bind animation to button click
  29. button.addEventListener('click', () => {
  30. animation.play();
  31. });
  32. ```
  33. **3. Complex Animations with GSAP Plugins:**
  34. - Utilize GSAP's extensive plugin library to achieve advanced animation effects like scrollMagic, scrollTrigger, and ScrollToPlugin.
  35. - This allows for fine-grained control over animation based on scroll position, viewport size, and other factors.
  36. ```
  37. JavaScript
  38. // Include ScrollTrigger plugin
  39. Webflow.require('gsap/ScrollTrigger');
  40. // Define animation with ScrollTrigger plugin
  41. const animation = TweenLite.fromTo(element, 1, { opacity: 0 }, { opacity: 1 }, {
  42. scrollTrigger: {
  43. trigger: element,
  44. start: 'top bottom',
  45. end: 'bottom top',
  46. },
  47. });
  48. ```
  49. # Need Help?
  50. Want to build a [custom webflow page](https://epyc.in/)?