I'm having issues getting Stellar.js to work for me in Wordpress. I am trying to have certain elements of a page scroll faster or slower than the natural scroll speed of the page, to create a parallax effect.
Can someone help me fix what I'm doing wrong here?
In my childtheme folder, I have two files; js/stellar.min.js
and js/parallax.js
.
In functions.php
I have the following to register and enqueue these:
add_action('wp_enqueue_scripts', 'add_scripts');
function add_scripts() {
if ( is_page( 'home' ) ) {
wp_enqueue_script('jquery');
wp_register_script('stellar', get_template_directory_uri() . "/js/stellar.min.js", array('jquery'));
wp_enqueue_script('stellar');
wp_register_script('parallax', get_template_directory_uri() . "/js/parallax.js", array('jquery'));
wp_enqueue_script('parallax');
}
}
Then in parallax.js
I have the following:
jQuery(function(){
jQuery(window).stellar({
horizontalScrolling: false,
verticalScrolling: true,
responsive: false,
scrollProperty: 'transform',
positionProperty: 'transform',
parallaxElements: true
});
});
Lastly, of course, on the elements to be parallax I have data-stellar-ratio="2"
.