0

Aim: To get full page front and reverse scroll without using any plugins. What I tried: Please click on this JSFiddle link for my code

Problem I am facing: Front scroll (from top to bottom) is working fine as you can check in the fiddle. But reverse scroll(when we go back to each div from bottom to top) is causing issues. Its hanging between two divs. I have commented out the piece of code in fiddle and Here is the code I tried to get reverse scroll:

if ((scrollPosition < lastScroll) && ($("#"+prevDiv).isOnScreen()) === true) {
      console.log("prev div in view");
      $('html,body').animate({
         scrollTop: $("#"+prevDiv).offset().top
       },'slow');
        $("#"+prevDiv).addClass("active");
        $("#"+currentDiv).removeClass("active");
      currentDiv = $("#"+prevDiv);
      return false;
  }
AKNair
  • 1,369
  • 1
  • 12
  • 24
  • I doubt there is a problem in your " if ". Try changing it. – WC2 Nov 21 '18 at 06:57
  • I tried using console to debug the code. Its entering the loop correctly. But active state is not updating correctly on divs. Request you to guide me through the error, you feel is causing this issue. – AKNair Nov 21 '18 at 07:22

0 Answers0