I'm using stellar.js for a parallax image effect. I'm trying to pass a variable to the stellar.js init function but it's not working. The plugin is initialized in my $(document).ready() function (NOT a requirement) where I also do a bit of math because I can't hardcode the numbers when I initialize stellar.js. Here's the code in question.
$(document).ready(function() {
var $height = $("img").height(); // i.e. $height = 1000px
var $offset = $height * .75; // i.e. $offset = 750px;
$(window).stellar({
horizontalScrolling: false,
verticalOffset: $offset
});
)};
If I just put in 750 as the verticalOffset in the stellar init function it works fine. However, using the $offset variable does not work as it seems to be out of scope of the $(window).stellar() function. Can anyone help me out with this? Any help is greatly appreciated.