jquery.touchSwipe链接问题

时间:2016-11-26 12:42:35

标签: jquery html css swipe

我正在使用jquery.touchSwipe插件,但我现在面临一个问题。

如果div中有任何链接,当您尝试打开该链接时它将无效,但是当您滑动时它将正常工作。

检查下面的代码。

$(function() {			
					//Enable swiping...
					$("#test").swipe( {
						//Generic swipe handler for all directions
						swipe:function(event, direction, distance, duration, fingerCount, fingerData) {
							$(this).html("You swiped " + direction+"<br><a href='http://www.google.com/'>google.com</a>" );	
						},
						//Default is 75px, set to 0 for demo so any distance triggers swipe
					   threshold:0
					});
				});
.box
{
	margin-top:20px;
	margin-bottom:20px;
	max-width:768px;
	height:300px;
	
	padding: 10px;
	background-color: #EEE;
	-webkit-border-radius: 6px;
	-moz-border-radius: 6px;
	border-radius: 6px;
	
	text-align:center;
	font-weight: 300;
	font-size: 20px;
	line-height: 36px;
	
	overflow:hidden;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="http://m.couponi.com.sa/jquery.touchSwipe.js"></script>

<div id="test" class="box">Swipe me
            
            
            <a href="http://www.google.com/">google.com</a>
            
            
            
            </div>

1 个答案:

答案 0 :(得分:0)

我得到了我的问题的解决方案。

能够点击/点按链接但也可以刷你的菜单,你需要使用一个可能为75的滑动阈值(不是零!)并确保没有&#34; A&#34;排除元素,或者您可以休息排除列表。

$(function() {          
                //Enable swiping...
                $("#test").swipe( {
                    //Generic swipe handler for all directions
                    swipe:function(event, direction, distance, duration, fingerCount, fingerData) {
                        $(this).html("You swiped " + direction+"<br><a href='http://www.google.com/'>google.com</a>" ); 
                    },
                    //Default is 75px, set to 0 for demo so any distance triggers swipe
    threshold: 75,
    excludedElements: ""
                });
            });