手机端左右滑动切换菜单

pull/62/head
TC_ZK 2018-05-14 08:27:46 +08:00
parent ac6aa072a2
commit 7d68471c42
2 changed files with 678 additions and 599 deletions

View File

@ -154,4 +154,44 @@ require(['jquery', 'bootstrap'], function ($, undefined) {
});
});
});
// 手机端左右滑动切换菜单栏
$("body").on("touchstart", function(e) {
startX = e.originalEvent.changedTouches[0].pageX;
startY = e.originalEvent.changedTouches[0].pageY;
});
$("body").on("touchend", function(e) {
moveEndX = e.originalEvent.changedTouches[0].pageX;
moveEndY = e.originalEvent.changedTouches[0].pageY;
X = moveEndX - startX;
Y = moveEndY - startY;
// 判断标准
//右滑
if ( X > 45 ) {
if ((Math.abs(X)-Math.abs(Y))>50) {
if($('.sidebar-toggle').length>0){
if (!$('body').attr('sidebar-open')) {
$('body').addClass('sidebar-open');
}
}else{
if (!$('body', parent.document).attr('sidebar-open')) {
$('body', parent.document).addClass('sidebar-open');
}
}
}
}
//左滑
else if ( X < -45 ) {
if ((Math.abs(X)-Math.abs(Y))>50) {
if($('.sidebar-toggle').length>0){
if (!$('body').attr('sidebar-open')) {
$('body').removeClass('sidebar-open');
}
}else{
$('body', parent.document).removeClass('sidebar-open');
}
}
}
});
});

File diff suppressed because it is too large Load Diff