Only swipeone is working with jGestures

前端 未结 7 2429
抹茶落季
抹茶落季 2021-02-10 09:56

I\'m trying to implement touch evens with jGestures. swipeone works fine but anything else (swipeleft, swiperight etc) is not firing.

7条回答
  •  旧巷少年郎
    2021-02-10 10:34

    replace the cases on line 1326 in version 0.90.1 with this code

                    if ( _bHasTouches && _bHasMoved === true && _bHasSwipeGesture===true) {
                        _bIsSwipe      = true;
                        _oDetails.type = 'swipe';
                        _vLimit        = $(window).height()/4;
                        _wLimit        = $(window).width()/4;
                        _sMoveY        = _oDetails.delta[0].lastY;
                        _sMoveX        = _oDetails.delta[0].lastX;
                        _sMoveYCompare = _sMoveY.toString().replace('-','');
                        _sMoveXCompare = _sMoveX.toString().replace('-','');
    
                        if(_sMoveX < 0){
                            if(_oDetails.delta[0].lastY < _vLimit) {
                                if(_sMoveYCompare < _vLimit) {
                                    _oDetails.type += 'left';
                                }
                            }
                        }else if(_sMoveX > 0){
                            if(_sMoveYCompare < _vLimit) {
                                _oDetails.type += 'right'
                            }
                        }else{
                            _oDetails.type += '';
                        }
    
                        if(_sMoveY < 0){
                            if(_sMoveXCompare < _wLimit) {
                                _oDetails.type += 'up'      
                            }
                        }else if(_sMoveY > 0){
                            if(_sMoveXCompare < _wLimit) {
                                _oDetails.type += 'down'
                            }
                        }else{
                            _oDetails.type += '';
                        }
                        // alert(_oDetails.type);
                        _$element.triggerHandler(_oDetails.type, _oDetails);
                    }
    

提交回复
热议问题