Magic Studio

专心做有逼格的APP!

js响应鼠标滚轮事件

js响应鼠标滚轮事件

 

 1var up = $('up'), down = $('down'), log;
 2 
 3[up, down].each(function(arrow) {
 4    arrow.setStyle('opacity', .1);
 5}
);
 6 
 7document.addEvent('mousewheel'function(event) {
 8    event = new Event(event);
 9 
10    /* Mousewheel UP */
11    if (event.wheel > 0{
12        up.setStyle('opacity'1);
13        down.setStyle('opacity', .1);
14        log = 'up';
15    }
 
16    /* Mousewheel DOWN*/
17    else if (event.wheel < 0{
18        up.setStyle('opacity', .1);
19        down.setStyle('opacity'1);
20        log = 'down';
21    }

22 
23    $('log').setHTML(log);
24 
25    var cls = function() {
26        [up, down].each(function(arrow) {
27            arrow.setStyle('opacity', .1);
28        }
);
29    }
.delay(100);
30}
);

 

参考样例http://demos111.mootools.net/Mousewheel 

posted on 2009-02-25 14:00  Mr 布鲁斯  阅读(2056)  评论(0编辑  收藏  举报

导航