Jump to content
  • 0

проблемка с mouse_wheel


Justus
 Share

Question

Добре. Содрал код с небезызвестной статьи по маус_вилл, кое-как его под себя адаптировал, задача в том, чтобы при прокрутке колеса каждому из 4х li поочередно присваивался класс. В файрфоксе работает правильно, в остальных браузерах, которые, очевидно, используют wheelDelta, отсчет прыгает через 1. Прошу помощи, сам понять не могу - то ли где-то синтаксис неправильный, то ли у wheelDelta значение не 120..

 

 

//ловит событие

window.onload = function() {
if (window.addEventListener) window.addEventListener("DOMMouseScroll", mouse_wheel, false);
window.onmousewheel = document.onmousewheel = mouse_wheel;
};
//считает номер li
var nav_num=0,
mouse_wheel = function(event) {
if (false == !!event) event = window.event;
var direction = ((event.wheelDelta) ? event.wheelDelta/120 : event.detail/-3) || false;
event.returnValue = false;
$('.nav_link').removeClass('mnu_active');
$('.hello').css('display', 'none');
nav_num -= direction;
if (nav_num>4) nav_num=1;
if (nav_num<1) nav_num=4;
$('.navigation li:nth-child('+(nav_num)+')').addClass('mnu_active');
};
 });
Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy