开发者

how to detect doubletap without triggering silgeltap in sencha touch

开发者 https://www.devze.com 2023-03-02 08:41 出处:网络
is there a smart and simple way to detect a doubletap without triggerin开发者_如何学Cg a silgeltap in sencha touch?

is there a smart and simple way to detect a doubletap without triggerin开发者_如何学Cg a silgeltap in sencha touch?

thnx!


I don't think there is a 'clean' way to do it. It will delay the single tap option by 300ms which may be unacceptable. You may want to simplify your UI interactions if you can. Maybe a tap and hold?

I found this code in the Sencha Touch forums.

setupEventHandlers: function(){
this.mon(this.el, {
    tap: function(e){            
        if(this.delayedTask == null){            
            //setup a delayed task that is called IF double click is not later detected
            this.delayedTask = new Ext.util.DelayedTask(
              function(){
                this.doSomethingInteresting(); 
                this.delayedTask = null;
              }, this);  

            //invoke (with reasonable time to cancel)
            this.delayedTask.delay(300);
        }                
    }, 
    doubletap: function(e){                
        //cancel and clear the queued single click tasks if it's there
        if(this.delayedTask != null){
          this.delayedTask.cancel();
          this.delayedTask = null;
        }                        

        //handle the double click
        this.doSomethingReallyInteresting();
    },        
    scope: this
});

},

0

精彩评论

暂无评论...
验证码 换一张
取 消