How to stop the swipe event in jQTouch whilst a sl

2019-06-04 12:28发布

问题:

I've almost finished a hybrid site and theres one issue I cant resolve (many due to the deliberate lack of documention on the now Sencha library).

I have a binded event on the swipe, left and right, proper animations, its just when I swipe quickly, or I swipe - the page starts to transition (slide) - whilest transisitoning I swipe again. I throws jQtouch and results in a black page.

$('div.touch').swipe(function(event, info){

        switch(info.direction){
            case 'left':
            jQT.goTo('#test', 'slide');
            break;

I'm thinking 'pageAnimationEnd' will probably be the event I need to use and tie in somehow. But pointers would be good, for a noob. :)

回答1:

I fixed the problem. If people have a better solution , let me know.

I created a singleton called "delay"

        var delay = (function(){

            wait = false;
            return {

                set:function(bool_wait){
                      wait = bool_wait;
                    },

                get:function(){
                  return wait;
                  }
              }
        })();

"I know its a global" , You can implement this anyway you want. Its the quick fix. Just put it in a script called delay.js and attach it to the beginning of ur document.

Now when you call "Swipe"

Do the following

$('#div.touch').swipe(function(e,info){

               if(delay.get() === false){

                switch(info.direction){
                       case 'left':
                       jQT.goTo('#test', 'slide');
                       break;
                }       

                 delay.set(true);
                 setTimeout(function(){delay.set(false)},1000);

              }
        });

This just puts a 1 second delay between swiping.