jqueryskrollr

Disabling Skrollr on mobile/screen resize, then re-enabling on desktop


How do I disable Skrollr on mobile, as well as accounting for screen resizes? (ie, destroying skrollr on screen resize would mean that everything breaks once the user resizes up again).


Solution

  • Using Jquery

    $(function () {
      if ($(window).width() > 480) { // initialize Skrollr under 480px
        skrollr.init();
      } else {
        skrollr.init().destroy();
      }
      $(window).on('resize', function () {
        if ($(window).width() <= 480) { // destroy Skrollr over 480px
          skrollr.init().destroy(); 
        } else {
          skrollr.init();
        }
      });
    });