2011-01-27 3 views
1

私はJavascriptイベント(私には全く外国の件名)で作業しており、モバイルサファリのタッチイベントを処理するためのガイダンスが必要です。タッチイベント(携帯サファリ)の位置を特定する

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

は、私は、ユーザーが現在触れているものは何でもスパン強調表示したい:

は、私のようなものに見える文書を持っています。

私は成功しますがhttp://www.jqtouch.com/

をチェックアウトする場合があります

答えて

1

私が試した解決策は、ドキュメントに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); 
    } 
} 
関連する問題