ScrollMagic
ScrollMagic copied to clipboard
Wordpress add scrollmagic
Hello, There is a guide to add scrollmagic and gsap to Wordpress without plugin? Because doesn't work and i don't understand if is the load problem or my code.
var controller = new ScrollMagic.Controller();
// build scene
var Scene = new ScrollMagic.Scene({
triggerElement: '#container-page',
triggerHook: 0.1
})
.setTween('#logo', {color:'#000'})
.addTo(controller);
functions.php :
wp_register_script('scrollmagic', get_template_directory_uri() . '/js/lib/scrollmagic.js', array('jquery'), '2.0.6');
wp_enqueue_script('scrollmagic');
wp_register_script('scripts', get_template_directory_uri() . '/js/scripts.js', array('jquery'), '1.0.0');
wp_enqueue_script('scripts');
scripts.js :
(function ($, root, undefined) {
$(function () {
'use strict';
var controller = new ScrollMagic.Controller();
// create a scene
new ScrollMagic.Scene({
duration: 100, // the scene should last for a scroll distance of 100px
offset: 50 // start this scene after scrolling for 50px
})
.setPin("#logo") // pins the element for the the scene's duration
.addTo(controller); // assign the scene to the controller
});
})(jQuery, this);
fo me it's work
Dunno if you are still interested but I just add in the header.php of my child theme
<script src="//cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.7/ScrollMagic.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.5.1/gsap.min.js"></script>
and I've add a Raw JS element, with the script.js from @NodokaMurmevent, to the page and it works perfectly!