• js监控鼠标滚动事件


    //滚动动画
                windowAddMouseWheel();
                function windowAddMouseWheel() {
                    var scrollFunc = function (e) {
                        e = e || window.event;
                        if (e.wheelDelta) {  //判断浏览器IE,谷歌滑轮事件
                            if (e.wheelDelta > 0) { //当滑轮向上滚动时
                                $("#my_top").slideDown("slow");
                                $("#sl_last").slideUp("slow");
                            }
                            if (e.wheelDelta < 0) { //当滑轮向下滚动时
                                $("#my_top").slideUp("slow");
                                $("#sl_last").slideDown("slow");
                            }
                        } else if (e.detail) {  //Firefox滑轮事件
                            if (e.detail> 0) { //当滑轮向上滚动时
                                $("#my_top").slideDown("slow");
                                $("#sl_last").slideUp("slow");
                            }
                            if (e.detail< 0) { //当滑轮向下滚动时
                                $("#my_top").slideUp("slow");
                                $("#sl_last").slideDown("slow");
                            }
                        }
                    };
                    //给页面绑定滑轮滚动事件
                    if (document.addEventListener) {
                        document.addEventListener('DOMMouseScroll', scrollFunc, false);
                    }
                    //滚动滑轮触发scrollFunc方法
                    window.onmousewheel = document.onmousewheel = scrollFunc;
                }

    参考大神写的,写博的时候网页关了,没找到原文地址,抱歉

  • 相关阅读:
    周末总结
    大数据开源框架技术汇总
    oracle迁移mysql总结
    梯度下降
    BFC的概念
    元素类型
    window10安装tensorflow
    学习使用git
    设计模式中的关系
    拟合圆
  • 原文地址:https://www.cnblogs.com/duanzhenzhen/p/10678645.html
Copyright © 2020-2023  润新知