롤러 이벤트 방법 봉인

2479 단어



    
        
    


    



// var box=document.getElementById('box'); mouseWheel(box,function(event,down){ // var width=this.offsetWidth; var height=this.offsetHeight; // if (down) { // , , 500 if (width>=500&&height>=500) { // width=500; height=500; }else{ // this.style.width=width+1+"px"; this.style.height=height+1+"px"; } // }else{ // , if (width<=300&&height<=300) { width=300; height=300; }else{ // this.style.width=width-5+"px"; this.style.height=height-5+"px"; } } });

js 봉인 부분
/*
    @author     Henry Zhang
    @date       2016-008-02
    @version    01(  )
*/ 
function mouseWheel(obj,fn){
    //      ff   
    var ff=navigator.userAgent.indexOf("Firefox");
    //        
    if (ff!=-1) {
        //  box      
        obj.addEventListener('DOMMouseScroll',wheel,false);
    }else{
        obj.onmousewheel=wheel;
    }
    //          
    function wheel(event){
        var event=event||window.event;
        var down=true;
        if (event.detail) {
            down=event.detail>0;
        }else{
            down=event.wheelDelta<0;
        }
        console.log(down);
        fn.apply(obj,[event,down]);
        /*
              :fn              
                apply()     ,               fn  
        */ 

        return false;
    }

}

좋은 웹페이지 즐겨찾기