0

I want to disable mousewheel for 1 second. How I can do this?

I have this function:

function clickOnMenu(id)
{

    switch(id)
    {
        case 1:
        $('.page').css('display','none');
        $('#first').click();
        rotateImage($('#first'));
        $('#menu div').removeClass('active');
        $('#first').addClass('active');
        break;

        case 2:
        $('.page').css('display','none');
        $('#feature').click();
        rotateImage($('#feature'));
        $('#feature').addClass('active');
        break;

        case 3:
        $('.page').css('display','none');
        $('#download').click();
        rotateImage($('#download'));
        $('#download').addClass('active');
        break;
    }
}

These cases run with mousewheel. I want when each case selected, mousewheel get disable for 1 second.

How I can do this?

thefourtheye
  • 221,210
  • 51
  • 432
  • 478
Chalist
  • 2,903
  • 5
  • 37
  • 65

1 Answers1

5

Attach an event listener to the mousewheel that does nothing. Remove the event listener after 1 second.

$('#foo').on('mousewheel', function(e){
  e.preventDefault();
  return false;
}

setTimeout(function() {
  $('#foo').off('mousewheel');
}, 1000);
xbonez
  • 40,730
  • 48
  • 157
  • 236