zoukankan      html  css  js  c++  java
  • js判断鼠标滚轴方向(向上或向下)

    var num=1;
        $(document).on("mousewheel DOMMouseScroll", function (e) {
            var delta = (e.originalEvent.wheelDelta && (e.originalEvent.wheelDelta > 0 ? 1 : -1)) ||  // chrome & ie
                    (e.originalEvent.detail && (e.originalEvent.detail > 0 ? -1 : 1));              // firefox
            var tt;
            tt="scale("+num+")";
            $(".cc").css({"transform":tt});
            if (delta > 0) {
                if(num<6){
                    ++num;//向上滚的话 让元素放大
                    console.log(num)
                }
                // 向上滚
                console.log("wheelup");
    
            } else if (delta < 0) {
                // 向下滚
                if(num>1){
                    --num;//向下滚的话  让元素缩小
                    console.log("wheeldown");
                }
    
            }
        });
  • 相关阅读:
    UVa 482
    UVa 10360
    UVa 10812
    UVa 10420
    UVa 573
    UVa 357
    UVa 147
    UVa 674
    郑厂长系列故事——逃离迷宫 HDU4524
    威威猫系列故事——过生日 HDU 4523
  • 原文地址:https://www.cnblogs.com/dongxiaolei/p/8073574.html
Copyright © 2011-2022 走看看