Hi everyone,
I want to start using gsap with wordpress, but it doesnt seem to work. What am I doing wrong?
I use a child theme (with Enfold). This childtheme contains a file called functions.php with (only) the following content:
<?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-js', 'https://cdnjs.cloudflare.com/ajax/libs/gsap/3.6.1/gsap.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' );
?>
In my child-theme I made a folder called "js" and putted a file called "custom-gsap-scripts.js" in it with the following content:
gsap.to(".testimage", {duration: 2, x: 500});
In my wordpress I linked this testimage to the following way. The Image appears - but no animation so far:
<img class="testimage" src="/wp-content/uploads/2021/04/content.png" alt="" width="500" height="500" />