Search code examples
javascriptstellar.js

What does $(window).stellar do?


I currently have this code (it's not written by me):

$(window).stellar({
    horizontalScrolling: false,
    responsive: true
});

Now, I'm curious about what it actually does. I did comment it but I didn't see any changes, but before I ruin something, I'd like to know what it does so I can decide whether to keep it in or not.


Solution

  • It seems to be activating this plugin:

    http://markdalgleish.com/projects/stellar.js/

    Its documentation says what those options do:

    Configuring Offsets

    Stellar.js' most powerful feature is the way it aligns elements.

    All elements will return to their original positioning when their offset parent meets the edge of the screen—plus or minus your own optional offset. This allows you to create intricate parallax patterns very easily.

    Confused? See how offsets are used on the Stellar.js home page. To modify the offsets for all elements at once, pass in the options:

    $.stellar({
      horizontalOffset: 40,
      verticalOffset: 150
    });