ScrollMagic icon indicating copy to clipboard operation
ScrollMagic copied to clipboard

Wordpress add scrollmagic

Open iamalessiopaoletti opened this issue 7 years ago • 2 comments

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);

iamalessiopaoletti avatar Sep 27 '18 15:09 iamalessiopaoletti

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

NodokaMurmevent avatar Oct 12 '18 12:10 NodokaMurmevent

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!

tonytozoo avatar Nov 12 '20 00:11 tonytozoo