我为响应式页面(针对移动页面)编写了自定义可滑动侧边菜单:
这是代码:
jQuery code:
$(window).load(function(){
$("[data-toggle]").click(function() {
var toggle_el = $(this).data("toggle");
$(toggle_el).toggleClass("open-sidebar");
});
$(".swipe-area").swipe({
swipeStatus:function(event, phase, direction, distance, duration, fingers)
{
if (phase=="move" && direction =="right") {
$(".container").addClass("open-sidebar");
return false;
}
if (phase=="move" && direction =="left") {
$(".container").removeClass("open-sidebar");
return false;
}
}
});
});
HTML code:
<html>
<body>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript" src="https://github.com/mattbryson/TouchSwipe-Jquery-Plugin/blob/master/jquery.touchSwipe.min.js"></script>
<!-- <div id = "mainDiv" class = "container" style="padding:0px;width:100%;height:100%" data-role="page" id="pageone"> -->
<div data-role="page" id="pageone" class="container swipearea" id="mainDiv" style="padding:0px;width:100%;height:100%">
<div id = "header">
<span id = "icons">
<a href="#" data-toggle=".container" id="sidebar-toggle">
<span id = "menu"></span>
</a>
<span onclick="goBack()" id = "back"></span>
</span>
<span id = "title">
<span id="junos"> JUNOS </span><span id = "genius">GENIUS</span>
</span>
</div>
<!-- <div id ="body" class="container-fluid" style="position:relative;" data-role="main"> -->
<div id="body" class="container-fluid" style="position:relative;">
<div id="searchMenu" class="col-xs-4" style="height:400px; overflow-y:auto;padding:0px;display:none;min-width: 250px;background-color:transparent;">
</div>
<div id="sidebar">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Explore</a></li>
<li><a href="#">Users</a></li>
<li><a href="#">Sign Out</a></li>
<li><a href="#">Sign Out</a></li>
</ul>
</div>
</div>
</body>
</html>
jquery代码的编写方式是检测手指或鼠标光标的运动 但是当我向右滑动时,侧面菜单不会出现。错误在哪里?