Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
YOHOBUYPC
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
2
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
梁志锋
9 years ago
Commit
80d017143623052deb4cb07dea1a625ea863c600
1 parent
cf8836ff
侧边栏滚动效果修改
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
11 deletions
static/js/home/home.js
static/js/home/home.js
View file @
80d0171
...
...
@@ -36,7 +36,7 @@ function stopPropagation(e){
e
.
cancelBubble
=
false
;
}
function
innerScroll
(
e
){
/**
function innerScroll(e){
// 阻止冒泡到document
// document上已经preventDefault
stopPropagation(e);
...
...
@@ -58,7 +58,7 @@ function innerScroll(e){
}
// 会阻止原生滚动
// return false;
}
}
**/
var
disableScroll
=
function
(){
$
(
document
).
on
(
'mousewheel'
,
preventDefault
);
...
...
@@ -77,8 +77,9 @@ var enableScroll = function(){
enableScroll();
});**/
// 内部可滚
$sideNav
.
on
(
'mousewheel'
,
innerScroll
);
// 内部可滚
$sideNav
.
on
(
'touchmove mousewheel'
,
stopPropagation
);
// 外部禁用
disableScroll
();
...
...
@@ -91,7 +92,7 @@ $sideNav.on('touchstart', function(e){
});
// 仿innerScroll方法
$sideNav
.
on
(
'touchmove'
,
function
(
e
){
/**
$sideNav.on('touchmove', function(e){
e.stopPropagation();
var deltaX = e.originalEvent.touches[0].pageX - startX;
...
...
@@ -119,7 +120,7 @@ $sideNav.on('touchmove', function(e){
}
// 会阻止原生滚动
// return false;
});
});
**/
$
(
'.nav-btn'
).
on
(
'touchstart'
,
function
(
event
)
{
$sideNav
.
css
(
'pointer-events'
,
'none'
);
...
...
@@ -131,10 +132,10 @@ $('.nav-btn').on('touchstart', function(event) {
openSideNav
=
true
;
//设置boy高宽,页面不能上下滑动
$
(
'body'
).
css
({
/**
$('body').css({
height: $(window).height(),
overflow: 'hidden'
});
});
**/
setTimeout
(
function
()
{
$sideNav
.
css
(
'pointer-events'
,
'auto'
);
...
...
@@ -150,10 +151,10 @@ function hideSideBar() {
$
(
'.overlay'
).
hide
();
$
(
'.sub-nav'
).
removeClass
(
'show'
);
$sideNav
.
removeClass
(
'on'
);
$
(
'body'
).
css
({
/**
$('body').css({
height: 'auto',
overflow: 'auto'
});
});
**/
enableScroll
();
}
}
...
...
@@ -178,7 +179,7 @@ $sideNav.on('touchend', 'li', function(e) {
//返回一级导航,收起二级导航
$subNav
.
each
(
function
()
{
$
(
this
).
find
(
'li'
).
eq
(
0
).
on
(
'touch
start
'
,
function
()
{
$
(
this
).
find
(
'li'
).
eq
(
0
).
on
(
'touch
end
'
,
function
()
{
$
(
'.sub-nav'
).
removeClass
(
'show'
);
return
false
;
});
...
...
Please
register
or
login
to post a comment