0

Im using parallax effect on my website and it kind of breaks when I change the window size to minimum and then back so I'm trying to check the width of the window with jquery, so when the width is less than lets say 800px (tablets and mobile devices) dont initialize the plugin.

So far I have this:

<script src="js/parallax.js"></script>

and

<script type="text/javascript">

$(document).ready(function() {
    $(window).resize(function() {
        var width = $(window).width();

        if(width > 900) {
            $('header').parallax("50%", 0.5);
            $('footer').parallax("50%", 0.5);
        }
    });
});

</script>

Maybe the best thing would be to check if the device is mobile and then dont load the plugin at all, but I dont know how to do that.

Andrea Ligios
  • 49,480
  • 26
  • 114
  • 243
Richard Mišenčík
  • 324
  • 1
  • 8
  • 19

1 Answers1

0

Did you tried this?

$(window).resize(function() {
     if($(window).width() < 900)
         $('header').parallax("50%", 0.5);
         $('footer').parallax("50%", 0.5);
});
Nick
  • 82
  • 9