MegaS
MegaS

Reputation: 77

Disable and enable script based on scroll

I have scrollify set up so that it will on the last section disable and scroll normally, but when you come back to the last section in the reverse (i.e. scroll up not down the page) it doesn't re-enable itself.

<script id="scrollify" src="assets/js/jquery.scrollify.js"></script>
<script>
  $(document).ready(function() {
    $.scrollify({
      interstitialSection : ".scroll-wrapper",
      updateHash: false,
      touchScroll:true,
      scrollSpeed: 1200,
    });
  });

  $(document).on('scroll', function(e){
    var top = $('.page-section:last').offset().top;
    var screenTop = $(document).scrollTop();
    if (top > screenTop && $.scrollify.isDisabled()) {
      $.scrollify.enable();
      $.scrollify.update();
    } else if (top < screenTop && !$.scrollify.isDisabled()) {
      $.scrollify.disable();
    }
  });
</script>

Is it possible to do the reverse of this function?

Upvotes: 1

Views: 283

Answers (0)

Related Questions