質問

私はJavaScriptイベント(私にとって完全に異質なテーマ)と協力しており、モバイルSafariでのタッチイベントの取り扱いに関するガイダンスが必要です。

次のようなドキュメントがあります。

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

ユーザーが現在触れているどんなスパンでも強調表示したいと思います。

私は正常に行きました

役に立ちましたか?

解決

私が作った解決策は、ドキュメントに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);
    }
}

他のヒント

チェックアウトしたいかもしれません http://www.jqtouch.com/

「Tap」と呼ばれるイベントを作成します https://github.com/senchalabs/jqtouch/wiki/callbackevents

JQTouchのデモでここでプレイできます http://www.jqtouch.com/preview/demos/main/#home

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top