Jump to content
Search Community

Problem with gsap.registerPlugin(ScrollTrigger) in WordPress

Benny test
Moderator Tag

Recommended Posts

Hi everyone,

I'm new at all this, and just finally hopped onboard gsap with the ScrollTrigger plugin release. But now I've run into a basic installation issue and can't seem to find similar in the forums.

 

This is the only code I've left uncommented for gsap:

window.onload = function(){
//timeline functions
//HOME PAGE CONDITION
if( ishome() ) {
//Scroll */
gsap.registerPlugin(ScrollTrigger);

 

I get this error:
image.thumb.png.eb450f2dfaf5503850b586532e234150.png

At the registration call. And the code inside indicates that the body element is undefined:
image.png.7308234249ab4c1763474133eccddea5.png


So the problem isn't likely the source files or body tag. The environment is a wordpress install and the files are called with the following enqueue function. As a result of all this trail and error I've tried unminified versions, I've run the files locally instead of CDN, and included map files when calling minified files. I'm running out of ideas.
 

function neon_enqueue()
{
 
wp_enqueue_style( 'neon-css', get_template_directory_uri() . '/dist/css/style.css', array(), '1.0.0', 'all' );
//wp_enqueue_script( 'greensock', 'https://cdnjs.cloudflare.com/ajax/libs/gsap/3.3.0/gsap.min.js', array(), '3.3', false );
wp_enqueue_script( 'greensock', get_template_directory_uri() . '/dist/js/gsap.min.js', array(), '3.3', false );
wp_enqueue_script( 'scrolltrigger', 'https://cdnjs.cloudflare.com/ajax/libs/gsap/3.3.0/ScrollTrigger.js', array('greensock'), '3.3', false );
wp_enqueue_script( 'theme-js', get_template_directory_uri() . '/dist/js/theme.js', array(), '1.0.0', false);
wp_enqueue_script( 'footer-js', get_template_directory_uri() . '/dist/js/footer.js', array('gs-animation-library'), '1.0.0', true);
}

 

I know this is a local environmental issue and not reproducible, but it has to be something really simple I'm not understanding right.

 

Anyone have some insight here?

Thanks!

 

Link to comment
Share on other sites

It was simple. So simple that I'm not sure I should leave the post up but for fellow WP devs just setting this up who  load libraries in the header, the ScrollTrigger actually runs the dom so always enqueue in the footer.

 

Not sure if that was mentioned in the docs or not. If it was I missed it.

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...