首页 > 技术文章 > 固定导航,可以鼠标上划显示,下滑隐藏

kPedestrian 2016-08-09 11:09 原文

 

 1 function Navigater(obj) {
 2     var dom = document.getElementById(obj.dom);
 3     this.slide = function() {
 4         window.onmousewheel = function(e) {
 5             e = e || window.event;
 6             console.log(document.body.scrollTop);
 7             console.log(dom);
 8             // 判断鼠标是上滑动,还是下滑动
 9             if (e.wheelDelta) { // ie,google
10                 if (e.wheelDelta > 0) {
11                     dom.setAttribute('class', 'byq_navigater show');
12                 } else if (e.wheelDelta < 0) {
13                     dom.setAttribute('class', 'byq_navigater');
14                 }
15             } else if (e.detail) { // firefox
16                 if (e.detail > 0) {
17                     dom.setAttribute('class', 'byq_navigater show');
18                 } else if (e.detail < 0) {
19                     dom.setAttribute('class', 'byq_navigater');
20                 }
21             }
22         }
23     }
24 }

 

推荐阅读