Hello,
i successfully installed gsap too my wordpress website. Now i wanted to implement scrolltrigger into it as well.
This is my functions.php:
<?php
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;
/**
* Child theme functions
*/
if ( !function_exists( 'rewon_child_theme_css' ) ):
function rewon_child_theme_css() {
wp_enqueue_style( 'rewon_child_theme_CSS', trailingslashit( get_stylesheet_directory_uri() ) . 'style.css');
}
endif;
add_action( 'wp_enqueue_scripts', 'rewon_child_theme_css', 99 );
function enqueue_my_custom_script() {
wp_enqueue_script( 'gsap-js', 'https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js', false );
wp_enqueue_script( 'gsap-st', 'https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/ScrollTrigger.min.js', array('gsap-js'), false, true );
}
add_action( 'wp_enqueue_scripts', 'enqueue_my_custom_script' );
and this is my code on the page i wanted to testing the plugin:
<div class="boxtest2"></div>
<script>gsap.registerPlugin(ScrollTrigger);gsap.to(".boxtest2", { scrollTrigger: ".boxtest2", x: 500, rotation: 360, duration: 5 });</script>
If i take out "gsap.registerPlugin(ScrollTrigger);" then the animation is working but not with scrolltrigger.
Is the code in the functions.php right?