Authored by hf

Merge branch 'beta/wap' of http://git.dev.yoho.cn/web/yohobuy into beta/wap

... ... @@ -1707,6 +1707,97 @@ var start = 0,
lazyLoad($('img.lazy'));
function preventDefault(e) {
e = e || window.event;
e.preventDefault && e.preventDefault();
e.returnValue = false;
}
function stopPropagation(e){
e = e || window.event;
e.stopPropagation && e.stopPropagation();
e.cancelBubble = false;
}
/**function innerScroll(e){
// 阻止冒泡到document
// document上已经preventDefault
stopPropagation(e);
var delta = e.wheelDelta || e.detail || 0;
var box = $(this).get(0);
if($(box).height() + box.scrollTop >= box.scrollHeight){
if(delta < 0) {
preventDefault(e);
return false;
}
}
if(box.scrollTop === 0){
if(delta > 0) {
preventDefault(e);
return false;
}
}
// 会阻止原生滚动
// return false;
}**/
/**var disableScroll = function(){
$(document).on('mousewheel', preventDefault);
$(document).on('touchmove', preventDefault);
};
var enableScroll = function(){
$(document).off('mousewheel', preventDefault);
$(document).off('touchmove', preventDefault);
};
// 内部可滚
$sideNav.on('touchmove mousewheel', stopPropagation);
// 外部禁用
disableScroll();
// 移动端touch重写
var startX, startY;
$sideNav.on('touchstart', function(e){
startX = e.originalEvent.touches[0].pageX;
startY = e.originalEvent.touches[0].pageY;
});**/
// 仿innerScroll方法
/**$sideNav.on('touchmove', function(e){
e.stopPropagation();
var deltaX = e.originalEvent.touches[0].pageX - startX;
var deltaY = e.originalEvent.touches[0].pageY - startY;
// 只能纵向滚
if(Math.abs(deltaY) < Math.abs(deltaX)){
e.preventDefault();
return false;
}
var box = $(this).get(0);
if($(box).height() + box.scrollTop >= box.scrollHeight){
if(deltaY < 0) {
e.preventDefault();
return false;
}
}
if(box.scrollTop === 0){
if(deltaY > 0) {
e.preventDefault();
return false;
}
}
// 会阻止原生滚动
// return false;
});**/
$('.nav-btn').on('touchstart', function(event) {
$sideNav.css('pointer-events', 'none');
$mobileWrap.addClass('menu-open');
... ... @@ -1740,6 +1831,7 @@ function hideSideBar() {
height: 'auto',
overflow: 'auto'
});
//enableScroll();
}
}
... ... @@ -1749,7 +1841,7 @@ $('.overlay').on('touchstart', function(e) {
});
//点击一级导航,弹出二级导航
$sideNav.on('touchstart', 'li', function(e) {
$sideNav.on('touchend', 'li', function(e) {
if ($(this).find('.sub-nav').size() > 0) {
$('.sub-nav').removeClass('show');
$(this).find('.sub-nav').addClass('show');
... ... @@ -1763,7 +1855,7 @@ $sideNav.on('touchstart', 'li', function(e) {
//返回一级导航,收起二级导航
$subNav.each(function() {
$(this).find('li').eq(0).on('touchstart', function() {
$(this).find('li').eq(0).on('touchend', function() {
$('.sub-nav').removeClass('show');
return false;
});
... ...
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
... ... @@ -24,6 +24,97 @@ var start = 0,
lazyLoad($('img.lazy'));
function preventDefault(e) {
e = e || window.event;
e.preventDefault && e.preventDefault();
e.returnValue = false;
}
function stopPropagation(e){
e = e || window.event;
e.stopPropagation && e.stopPropagation();
e.cancelBubble = false;
}
/**function innerScroll(e){
// 阻止冒泡到document
// document上已经preventDefault
stopPropagation(e);
var delta = e.wheelDelta || e.detail || 0;
var box = $(this).get(0);
if($(box).height() + box.scrollTop >= box.scrollHeight){
if(delta < 0) {
preventDefault(e);
return false;
}
}
if(box.scrollTop === 0){
if(delta > 0) {
preventDefault(e);
return false;
}
}
// 会阻止原生滚动
// return false;
}**/
/**var disableScroll = function(){
$(document).on('mousewheel', preventDefault);
$(document).on('touchmove', preventDefault);
};
var enableScroll = function(){
$(document).off('mousewheel', preventDefault);
$(document).off('touchmove', preventDefault);
};
// 内部可滚
$sideNav.on('touchmove mousewheel', stopPropagation);
// 外部禁用
disableScroll();
// 移动端touch重写
var startX, startY;
$sideNav.on('touchstart', function(e){
startX = e.originalEvent.touches[0].pageX;
startY = e.originalEvent.touches[0].pageY;
});**/
// 仿innerScroll方法
/**$sideNav.on('touchmove', function(e){
e.stopPropagation();
var deltaX = e.originalEvent.touches[0].pageX - startX;
var deltaY = e.originalEvent.touches[0].pageY - startY;
// 只能纵向滚
if(Math.abs(deltaY) < Math.abs(deltaX)){
e.preventDefault();
return false;
}
var box = $(this).get(0);
if($(box).height() + box.scrollTop >= box.scrollHeight){
if(deltaY < 0) {
e.preventDefault();
return false;
}
}
if(box.scrollTop === 0){
if(deltaY > 0) {
e.preventDefault();
return false;
}
}
// 会阻止原生滚动
// return false;
});**/
$('.nav-btn').on('touchstart', function(event) {
$sideNav.css('pointer-events', 'none');
$mobileWrap.addClass('menu-open');
... ... @@ -57,6 +148,7 @@ function hideSideBar() {
height: 'auto',
overflow: 'auto'
});
//enableScroll();
}
}
... ... @@ -80,7 +172,7 @@ $sideNav.on('touchend', 'li', function(e) {
//返回一级导航,收起二级导航
$subNav.each(function() {
$(this).find('li').eq(0).on('touchstart', function() {
$(this).find('li').eq(0).on('touchend', function() {
$('.sub-nav').removeClass('show');
return false;
});
... ...