How to disable Stellar.js on window resize?

728 Views Asked by At

I've used Stellar.js to create parallax movement for full window sizes. I tried wrapping the script in an if statement to detect window size but that doesn't seem to work. How do I disable it when the window size is lower than 1600px? Thanks so much!

Js:

if ($(window).width() < 1600) {
  $.stellar.positionProperty.dgnl = {
      setTop: function($el, newTop, originalTop) {
          $el.css({
              'top': newTop,
              'right': $el.hasClass('dgnl') ? originalTop - newTop : 0
          });
      },
      setLeft: function($el, newLeft, originalLeft) {
          $el.css('right', newLeft);
      }
  };

  $.stellar({
      horizontalScrolling: false,
      positionProperty: 'dgnl'
  });
};
0

There are 0 best solutions below