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
  • 233,700
  • 52
  • 457
  • 497
Chalist
  • 3,160
  • 5
  • 39
  • 68

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);
Ayush
  • 41,754
  • 51
  • 164
  • 239