Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
210 views
in Technique[技术] by (71.8m points)

jquery - ios6 touch event handling javascript

I am trying to improve the touchwipe js. where i want to hanlde only horizontal scroll and if its any vertical scrolling comes up let browser handle my fix works fine in ios5 but in ios6 its getting frezee any idea ?

http://archive.plugins.jquery.com/project/Touchwipe-iPhone-iPad-wipe-gesture

Please find code following

function onTouchMove(e) {   

         //var e = (e.changedTouches != undefined)? touches[0] : e; 
         if(isMoving) {              
             var x = e.touches[0].pageX;
             var dx = startX - x;
             if(Math.abs(dx) >= config.min_move_x)
             {
                 if(config.preventDefaultEvents) { 
                     e.preventDefault();                 
                 }
                cancelTouch();
                if(dx > 0) {
                    config.wipeLeft();
                }
                else {
                    config.wipeRight();
                }
                return false;
            }
             else {
                   console.log('y moving.. ');
                   // attachTouch();
                    return true;
             }
         }

     }

Just adding some more details . I am trying to animate my list horizontal by BXslider and its works fine want to support the touch events so added the touch wipe jquery . But adding it give 1 issue that's horizontal scroll animation works ok but touch page vertical scroll not works.

So i tried to fixed issue by return true; if its only Y move, at touchwipe js. This fix working fine on android4 and ios5 but fails in ios6 if i scroll my page vertically little aggressively(moving finger in oval/circle for 4-5 sec) its freez bxslider animation.

further debugging give inside that bxslider.gotoNextSlide()-> calling the Jquery $parent.animate() method for sliding which stop working in ios6 after aggressive scroll.

Now i m stuck and not able to understand why this animate() stops working ??

EG >>>

http://jsfiddle.net/qtCHx/

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This probably happens due to this bug: http://bugs.jquery.com/ticket/12620

A temporary solution here: https://gist.github.com/3798925


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...