Jump to content
Search Community

matt antony

Members
  • Posts

    1
  • Joined

  • Last visited

Posts posted by matt antony

  1. On 11/5/2019 at 6:23 PM, jake-adams said:

     

    This didn't actually work for me - not sure if anyone else is having the same issue.

     

     I tweaked the second row from gsap-js, to gsap-script and it started working straight away!

     

    
        wp_enqueue_script( 'gsap-js', 'http://cdnjs.cloudflare.com/ajax/libs/gsap/2.1.1/TweenMax.min.js', array(), false, true );
        wp_enqueue_script( 'gsap-script', get_stylesheet_directory_uri() . '/js/gsap-scripts.js', array(), false, true );

     

    On 2/25/2019 at 10:00 PM, Jonathan said:

    Hi @Gianluca Giurlando and welcome to the GreeenSock Forum!

     

    Yes that is still valid.

     

    On the frontend of your website, check the browser dev tools Network panel and make sure your GSAP CDN script is being run/loaded before your custom GSAP script JS file. This way your custom code runs after GSAP is already loaded

     

    Also you might have to add a DOM ready event and window load event to make sure your code is running when the HTML markup (DOM) and window is fully loaded.

     

    
    // wait until DOM is ready
    document.addEventListener("DOMContentLoaded", function(event) {
      
      console.log("DOM loaded");
      
      // wait until images, links, fonts, stylesheets, and js is loaded
      window.addEventListener("load", function(e) {
        
        // custom GSAP code goes here
         console.log("window loaded");
        
      }, false);
      
    });

     

    Check your dev tools console to make sure you see those output console logs.

     

    
    <?php
    // The proper way to enqueue GSAP script
    // wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer );
    function theme_gsap_script() {
        wp_enqueue_script( 'gsap-js', 'http://cdnjs.cloudflare.com/ajax/libs/gsap/2.1.1/TweenMax.min.js', array(), false, true );
        wp_enqueue_script( 'gsap-js2', get_template_directory_uri() . '/js/custom-gsap-scripts.js', array(), false, true );
    }
    add_action( 'wp_enqueue_scripts', 'theme_gsap_script' );
    ?>

     

    The link to the WordPress Codex for enqueuing JS files:

     

    http://codex.wordpress.org/Function_Reference/wp_enqueue_script

     

    For easy reference:

     

     

    Happy Tweening!

     

    Thank you jake jake-adams - you helped me a lot. I am grateful. I knew it was a scripting issue with wordpress. Been looking for this answer everywhere. Nowhere on the internet can you find the correct way. ONCE AGAIN - AMAZING JOB.  Issue Solved. 

×
×
  • Create New...