1

アプリケーションにjQuerymobileを使用しています。

jQuery Mobileを使用してジェスチャをリリースすることは可能ですか?ユーザーが指を置いて画面をドラッグした場合、画面に指を置いたままでも、JavaScriptを使用してこのジェスチャを解放できますか?

たとえば、1000ミリ秒後にタッチムーブを解放して、イベントが終了するようにすることは可能ですか$(this).touchend();(私ができるように$(this).click();)?

編集: 一方、誰かがtouch/touchmove時間を制限する方法について他のアイデアを持っているかもしれませんか?

4

2 に答える 2

5

を呼び出すことで、任意のイベントをトリガーできます。このメソッドのjQueryドキュメント$(this).trigger(eventName)を 参照してください。

あなたのケースは次のようになります:$(this).trigger('touchend');

1000msのタッチ後に発生するイベントが必要な場合は、jQMのtapholdイベントを検討してください。を設定して遅延を指定できます$.event.special.tap.tapholdThreshold

于 2012-11-21T13:38:20.063 に答える
1

このようなものは機能しますか?

JS

function bindEventTouch(element) {
    element.bind('tap taphold swipe swiperight swipeleft', function(event, ui) {
        console.log('Event: '+event.type); 

        if(event.type == 'taphold') {
            console.log('Was Event taphold?: '+event.type); 
            element.trigger('touchend');
        }
    });

    element.bind('touchend', function(event, ui) {
        console.log('Triggered touchend Event: '+event.type); 
    });
}

$('.displayEvent').each(function(){
    bindEventTouch($(this));
});​

HTML

<div data-role="page" id="home"> 
    <div data-role="content">
        <div id="display-event-1" class="add-border displayEvent">
            <p>Tap, TapHold (for 1 second), Swipe, SwipeRight or SwipeLeft</p>
        </div>
        <br />
        <div id="display-event-2" class="add-border displayEvent">
            <p>Tap, TapHold (for 1 second), Swipe, SwipeRight or SwipeLeft</p>
        </div>
        <br />
        <div id="display-event-3" class="add-border displayEvent">
            <p>Tap, TapHold (for 1 second), Swipe, SwipeRight or SwipeLeft</p>
        </div>
    </div>
</div>​

CSS

.add-border {
    border-style:solid;
    border-width:1px;
    width:100%;   
    text-align:center;
}​
于 2012-11-21T13:57:13.457 に答える