开发者

How to stop the swipe event in jQTouch whilst a slide transition is occuring?

开发者 https://www.devze.com 2023-02-18 15:11 出处:网络
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'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){
开发者_如何学Python            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. :)


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.

0

精彩评论

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