Show/Hide on Scroll working when I remove JQuery-Migrate-3

164 Views Asked by At

I have code that works when I remove JQuery Migrate 3.0.1 but when I add it back the code no longer works.

I need Migrate as this is a very old site and I am trying to add new features to it... here is the code I am using. I tried $(window).scroll(function(){... as opposed to $(window).on("scroll"...

I know this is something simple I am missing. Any help appreciated.

    $(window).on("scroll", function() {

      var $this = $(this),
          scrolled = $this.scrollTop(),
          winHeight = $this.height(),
          viewBottom = scrolled + winHeight;
      if (viewBottom >= $desktopISI.offset().top + $floatISIHeight) {
        console.log(viewBottom + " viewBottom");
        console.log($desktopISI.offset().top + " offsetTop");
        $floatingISI.addClass("hide");
      } 
      else {
        $floatingISI.removeClass("hide");
      }
    });


    $(window).on("scroll", function() {
      var $this = $(this),
          scrolled = $this.scrollTop(),
          winHeight = $this.height(),
          viewBottom = scrolled + winHeight;
      if (viewBottom >= $desktopISI.offset().top || viewBottom >= $(document).height() - $floatISIHeight) {
        $floatingISI.addClass("hide");
      }
      else {
        $floatingISI.removeClass("hide");
      }

    });
0

There are 0 best solutions below