How do I enqueue Tweenmax in the functions.php file?

Hi there,

I’m trying to add Tweenmax to my site.

I added the TweenMax.min.js life to the js > dist > site directory and this is the enqueue script I loaded at the end of the functions.php file:

function my_assets() {
wp_enqueue_script( ‘tweenmax-scripts’, get_stylesheet_directory_uri() . ‘/js/dist/site/TweenMax.min.js’, array( ‘tweenmax’, ‘jquery’ ), ‘1.20.4’, true );
}
add_action( ‘wp_enqueue_scripts’, ‘my_assets’ );

However, this code isn’t loading the Tweenmax scripts. Am I missing something or did I write my enqueue script incorrectly?

Hi There,

Please update your code to this:

function my_assets() {
	wp_enqueue_script( 'tweenmax-scripts', get_stylesheet_directory_uri() . '/js/dist/site/TweenMax.min.js', array( 'jquery' ), '1.20.4', true );
}
add_action( 'wp_enqueue_scripts', 'my_assets' );

And make sure the file x-child/js/dist/site/TweeMax.min.js exists.

Regards!

It’s been enqueued now, thanks!

But for some reason my tweening animations aren’t working. I’m adding them to the custom JS, this is what it looks like:

jQuery(document).ready(function($) {
var controller = new ScrollMagic.Controller();
// build Tween
var fadeIn = new TweenMax.to(’#man’, 0.5, {
opacity: 1,
color: ‘red’,
});
// build scene
var whenInContainer = new ScrollMagic.Scene({
triggerElement: ‘#second’,
offset: 250
})
.setTween(fadeIn)
.addIndicators()
.addTo(controller);
});
TweenMax.to("#man", 1, {x:500, repeat:0, yoyo:false})

Hi There,

Thanks for writing in! To assist you with this issue, we’ll first need you to provide us with your URL. This is to ensure that we can provide you with a tailored answer to your situation. Once you have provided us with your URL, we will be happy to assist you with everything.

Thank you.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.