Skip to content

Instantly share code, notes, and snippets.

@kurt-chainlink
Last active January 15, 2024 17:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kurt-chainlink/b5c700964f290f826d0e3275b5c179f0 to your computer and use it in GitHub Desktop.
Save kurt-chainlink/b5c700964f290f826d0e3275b5c179f0 to your computer and use it in GitHub Desktop.
Adding GSAP to the Divi Theme (full explanation here https://chainlinkmarketing.com/how-to-add-gsap-to-the-divi-theme-in-wordpress/)
// wait until DOM is ready
document.addEventListener("DOMContentLoaded", function (event) {
// wait until images, links, fonts, stylesheets, and js is loaded
window.addEventListener("load", function (e) {
//only run code on frontend of site (not when logged in making edits)
if (document.body.classList.contains('wp-admin')) {
} else {
//register GSAP plugins
gsap.registerPlugin(ScrollTrigger, ScrollToPlugin);
// custom GSAP code goes here
//small example of GSAP
gsap.from('#example-1',{autoAlpha:0});
gsap.set('.example-2',{scale:1.2});
//end of custom GSAP for site
}
// end of checking logged in
}, false);
});
@kurt-chainlink
Copy link
Author

kurt-chainlink commented Jan 15, 2024

Full article written on the Chainlink Marketing's website found here: "How to Add GSAP to the Divi Theme in WordPress" including:

  1. Make sure you have a Child Divi Theme Installed and Activated
  2. Find the appropriate GSAP files needed for your desired animations
  3. Call the GSAP scripts on your site by adding them to the Header Code
  4. Create a custom gsap-animations.js file to call/create your GSAP animations
  5. Register any necessary GSAP plugins required for your code
  6. Write your awesome code
  7. Upload your new custom JS file to your site
  8. Call your new custom JS file to trigger your animations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment