0

I'm trying to disable scroll counter after user scrolls up or down and while animation executing. I tried with timeouts but nothing worked. Timeout waited for 800ms with scrolling, but counter was still incerasing in the background.

I'm trying to achieve this functionality: https://alvarotrigo.com/fullPage/

My results so far: https://objemnarave.si/voda/index.php?lang=en

$('html').on('wheel', function(event) {
        if (event.originalEvent.deltaY > 0) {

//scroll down
        counter++;

//Check if counter is larger that section number, then execute animation
        if (!(counter > maxSections)) {
            $('html, body').animate({
                scrollTop: $( $(".sect-"+counter) ).offset().top
            }, 800);
        }

    } else {

//scroll up
        counter--;

//Check if counter is smaller than previous section
        if (!(counter < 1)) {
            $('html, body').animate({
                scrollTop: $( $(".sect-"+counter) ).offset().top
            }, 800);
        }
    }

    if (counter <= 0) {
        counter = 1;
    }
    else if (counter >= 13) {
        counter = maxSections;
    }
    console.log(counter);

});

It's possible to disable scroll counter in the backround while animation is executing?

Slasher
  • 568
  • 7
  • 29
  • Related: https://stackoverflow.com/questions/4770025/how-to-disable-scrolling-temporarily – Thaer A Apr 29 '20 at 11:57
  • I tried this also, but no success. Because this only stops transition visualy. But counter in the background keeps incerasing, causing animation to execute again after delay. – Slasher Apr 29 '20 at 12:00
  • 1
    Maybe create a variable AnimationRunning = 0 and check it with your if statements if (event.originalEvent.deltaY > 0 and AnimationRunning == 0 ), set it to 1 when animation is executing?.. if (!(counter > maxSections)) { AnimationRunning = 1; – Thaer A Apr 29 '20 at 12:12

0 Answers0