2013-02-12 1 views
6

누구든지이 코드에서 touchenter 이벤트가 작동하지 않는 이유를 알 수 있습니까? 마우스 센터는 바탕 화면에서 잘 작동합니다. 너무 간단해야하지만, 나는 뭔가 빠져있다. 여기touchenter 이벤트가 호출되지 않음

예 - 아래 http://jsfiddle.net/gCEqH/6/

전체 코드 :

는 가
<!DOCTYPE html> 
<html> 
    <head> 
     <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> 
    </head> 

    <body> 
     <img id="myImg" src="http://jackiehutchings.com/wp-content/uploads/2011/09/g-plus-icon-96x96.png" />   

     <script> 
      $(window).load(function() { 
      $('#myImg').on("touchenter mouseenter", function(event){ 
       alert('entered!'); 
      }); 
     }); 
     </script> 
    </body> 
</html> 
+0

Windows Phone에서 나에게 적합합니까? 어떤 브라우저? – enginefree

+0

Android 휴대 전화 또는 iPad에서 작동하지 않습니다. 전화에서 나는 표준 브라우저와 오페라를 모두 시도했다. – Justin

+0

ipad에서 나를 위해 잘 작동합니다. 당신이 그것에 일할 때 잘 작동합니다. 당신은 터치에 마우스를 올리려고하십니까? – karthik

답변

0

어쩌면이 같은 작업 것인가?

var elementIdTouching = ""; 
$('body').on("touchmove", function(e){ 
    var tList = e.touches; // get list of all touches 
    for (var i = 0; i < tList.length; i++) { 
     var thisTouch = tList[i]; // not 100% sure about this 
     var elementTouching = document.elementFromPoint( 
      thisTouch.screenX, 
      thisTouch.screenY 
     ); 
     if (elementTouching.id != elementIdTouching) { 
      elementIdTouching = elementTouching.id; 
      if (elementTouching.id == "myImg") { 
       alert("entered!"); 
      } 
     } 
    } 
}).on("touchend", function(e){ 
    elementIdTouching = ""; 
}); 
$('#myImg').on("mouseenter", function(e){ 
    alert('entered!'); 
}); 

TLIST ~ https://developer.mozilla.org/en-US/docs/Web/API/TouchList

면책 조항 :이 테스트하지 않았습니다.

+0

그 방법은 효과가 있지만 매우 느립니다. 나는 해결 방법을 생각해 냈다. (위의 내 의견 참조). – Justin

+0

quirksmode에 따르면'clientX'와'clientY'는'screenX'와'screenY'보다 더 나은 선택입니다 : http://www.quirksmode.org/dom/w3c_cssom.html#t20 – Webthusiast