Eveningstar

mousewheel.js 사용하기 본문

jQuery

mousewheel.js 사용하기

두루루루루 2018. 10. 21. 00:19

[ mousewheel.js ]


github : https://github.com/jquery/jquery-mousewheel

cdn: https://cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.13/jquery.mousewheel.min.js


마우스 휠 이벤트를 이용해 화면이 이동하거나 애니메이션이 작동되도록 할 수 있게 도와주는 플러그인



jquery.mousewheel.min.js


해당파일을 <script>에 넣어주기


   






jquery, jquery.easing, mousewheel 순으로 로드시켜주기

*DOMMouseScroll 은 파이어폭스용 이벤트명

   
$("div").on("mousewheel DOMMouseScroll", function(event, delta){
	if(delta>0){
  	//마우스 휠 up
    $(this).css("background", "red");
    $("p").text("마우스 휠을 위로!");
  }else if(delta<0){
  	//마우스 휠 down
	  $(this).css("background", "black");
    $("p").text("마우스 휠을 아래로!");    
  }  
});


예제연습

https://jsfiddle.net/jywoo/2L1pm04s/15/






출처 : 인터랙티브 웹디자인북

'jQuery' 카테고리의 다른 글

e.pageX, e.pageY  (0) 2018.10.20
[즐겨찾기]jQuery Cheat Sheet  (0) 2018.09.30
fading/sliding  (0) 2017.09.01
이벤트 다루기2/위치다루기  (0) 2017.08.28
이벤트 다루기  (0) 2017.08.27
Comments