Как сделать чтоб событие прокрутки тачпадом на ноутбуке срабатывало 1 раз?

У меня есть код, который отрабатывает скролл по одному блоку(По типу библиотек fullpage.js, и т.д.) Проблема заключается в том, что при скролле с ноутбука(тачпадом), событие отправляется много раз и перепрыгивает через два блока, как можно остановить событие, флаг задан, то есть он прокручивает(скролл запрещен), а после прокрутки еще раз прокручивает и останавливается. С мышки таких проблем нет, помогите пожалуйста.

    window.scrollTo({top: 0, behavior: 'smooth'});
let section_i = 0;
let section_i_before = 0;
let move = true;
let touchStartY = 0;
let section_i_length = 14;

let video = $('.mod-module1 .video-standart');
let videoRevers = $('.mod-module1 .video-revers');
if ($('body').hasClass('home')) {
    let programer_scroll = false;
    scroll_init();
    $(document).resize(function(){
        scroll_init();
    })

    function scroll_init() {
        let width = $(document).width();
        if (!$('body').hasClass('home')) {
            programer_scroll = false;
        } else if (width < 992) {
            $('body').removeClass('overflow');
            programer_scroll = false;
        } else {
            $('body').addClass('overflow');
            programer_scroll = true;
        }
    }
    $(document).on('wheel', function (e) {
        if (!programer_scroll) return false;
        if (scrolling) return false;
        let delta = e.originalEvent.deltaY < 0 ? -1 : 1;
        section_i += delta;
        if (section_i) $('.scroll-up').fadeIn();
        else $('.scroll-up').fadeOut();

        if (section_i < 0) section_i = 0;
        if (section_i >= section_i_length) {
            scrolling = true;
            //timer = 300;
            section_i_before = section_i_length;
            $('body').animate({
                scrollTop: $('footer').get(0).offsetTop
            }, 300,function() {
                scrolling = false;
                
            });
            return true;
        }
        move_to_screen(section_i)
        return false;
    });
    $(document).on('click touch', '.scroll-up', function() {
        section_i = 0;
        return true;
    })
    $('.mod-rightmenu .mod-list li').on('click touch', function() {
        $('.mod-rightmenu .mod-list li.navactive').removeClass('navactive');
        $(this).addClass('navactive');
        let sectionNumber = $(this).attr('id');
        section_i = parseInt(sectionNumber, 10);
        // console.log(sectionNumber);
        move_to_screen(section_i);
        return true;
    });
    
}


function move_to_screen(section_i) {
    // console.log(section_i_before);

    scrolling = true;
    timer = 1000;
    if (section_i_before == 14) timer = 300;
    let play = false;
    
    if (section_i >= 0 && section_i <= 14) {
        $('.mod-rightmenu .mod-list li.navactive').removeClass('navactive');
        $('.mod-rightmenu .mod-list li#' + section_i).addClass('navactive');
    }

    if (section_i_before < section_i) {
        switch (section_i) {
            case 3:     play = true; currentTime = 0;    timer = 2000;   break;
            case 4:     play = true; currentTime = 2;    timer = 2000;   break;
            case 5:     play = true; currentTime = 4;    timer = 2500;   break;
            case 6:     play = true; currentTime = 6.5;    timer = 2350;   break;
            case 7:     play = true; currentTime = 8.5;    timer = 4900;   break;
            case 8:     play = true; currentTime = 13.4;    timer = 5000;   break;
        }
        if (play && $(video).length > 0) {
            $(video).fadeIn(0);
            $(video).get(0).currentTime = currentTime;
            $(video).get(0).play();
        }

        $('#top_content > section').eq(section_i).find('.animation').addClass('animzxc');
    } else {
        switch (section_i) {
            case 2:     play = true; currentTime = 16;    timer = 2000;   break;
            case 3:     play = true; currentTime = 14;    timer = 2000;   break;
            case 4:     play = true; currentTime = 12;    timer = 2000;   break;
            case 5:     play = true; currentTime = 10;    timer = 1630;   break;
            case 6:     play = true; currentTime = 5;    timer = 5000;   break;
            case 7:     play = true; currentTime = 0;    timer = 4600;   break;
        }
        if (play && $(video).length > 0) {
            $(videoRevers).fadeIn(0);
            $(videoRevers).get(0).currentTime = currentTime;
            $(videoRevers).get(0).play();
        }
        $('#top_content > section').eq(section_i).find('.animation').addClass('animzxc');       
    }

    let item = $('#top_content > section:nth-child(' + (section_i + 1) + ')').get(0);

    if (item == undefined) return;
    if (section_i == 0) __top = 0;
    else __top = item.offsetTop;
    
    //console.log(__top);

    $('body').animate({
        scrollTop: __top
    }, timer, function() {
        if ($(video).length > 0) {
            $(video).get(0).pause();
            $(video).fadeOut();
        }
        if ($(videoRevers).length > 0) {
            $(videoRevers).get(0).pause();
            $(videoRevers).fadeOut();
        }

        scrolling = false;
        section_i_before = section_i;

        if ($(video).length > 0 && $(video).get(0).paused) {
            $('#top_content > section').eq(section_i).find('.animation').removeClass('animzxc');
        }
    });
}

Ответы (0 шт):