2011-01-27 2 views
1

자바 스크립트 이벤트 (나와 완전히 외국어 인 주제)로 작업 중이며 모바일 사파리의 터치 이벤트 처리에 대한 지침이 필요합니다.터치 이벤트에서 요소 찾기 (모바일 사파리)

<div> 
    <span>one</span><span>two</span> 
</div> 

나는 사용자가 현재 접촉 무엇이든 범위 강조 할 :

내가 좋아하는 뭔가를 보이는 문서가 있습니다.

나는 성공적

답변

1

와 함께 재생할 수 있습니다 "탭"이라는 이벤트를 생성 http://www.jqtouch.com/

체크 아웃 할 수 있습니다 이동했다 해결 방법은 문서에 eventListeners를 추가하는 것입니다.

document.addEventListener("touchstart", touchStart, "true"); 
    document.addEventListener("touchmove", touchMove, "true"); 
    document.addEventListener("touchend", touchEnd, "true"); 

다음으로 필요한 작업을 터치 이벤트로 수행하십시오. 나는 (정상적인 이벤트 처리에서와 같이) 위치를 가진 이벤트 자체가 아니라 위치를 가진 일련의 접촉이기 때문에 이것을 별표로 붙입니다.

function touchMove(event) 
{ 
    // // Prevent the webview itself from scrolling/bouncing around 
    event.preventDefault(); 
    // Only track one finger 
    if (event.touches.length == 1) 
    { 
     var touch = event.touches[0]; 
     doStuffAtPosition(touch.pageX, touch.pageY); 
    } 
} 
관련 문제