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

☆樱花仙子☆ 提交于 2019-12-08 06:15:30

问题


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.



来源:https://stackoverflow.com/questions/5380994/how-to-stop-the-swipe-event-in-jqtouch-whilst-a-slide-transition-is-occuring

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!