...
|
...
|
@@ -71,44 +71,99 @@ function setEditModeWithSknId(sknId, isThisGoodSelected) { |
|
|
isSelected = isThisGoodSelected;
|
|
|
}
|
|
|
|
|
|
function preventDefault(event) {
|
|
|
var e = event || window.event;
|
|
|
function preventDefault(e) {
|
|
|
e = e || window.event;
|
|
|
e.preventDefault && e.preventDefault();
|
|
|
e.returnValue = false;
|
|
|
}
|
|
|
|
|
|
var $target = $(e.target);
|
|
|
function stopPropagation(e){
|
|
|
e = e || window.event;
|
|
|
e.stopPropagation && e.stopPropagation();
|
|
|
e.cancelBubble = false;
|
|
|
}
|
|
|
|
|
|
if (($target.hasClass('.chose-items') || $target.closest('chose-items')) &&
|
|
|
($('.color-list').find('ul').not('.hide').find('li').length > 4 ||
|
|
|
$('.size-list').find('ul').not('.hide').find('li').length > 4)) {
|
|
|
e.stopPropagation();
|
|
|
return false;
|
|
|
}
|
|
|
function innerScroll(e){
|
|
|
var delta = e.wheelDelta || e.originalEvent.wheelDelta || e.detail || 0,
|
|
|
box = $(this).get(0);
|
|
|
|
|
|
// 阻止冒泡到document
|
|
|
// document上已经preventDefault
|
|
|
stopPropagation(e);
|
|
|
|
|
|
if (e.preventDefault) {
|
|
|
e.preventDefault();
|
|
|
|
|
|
if($(box).height() + box.scrollTop >= box.scrollHeight){
|
|
|
if(delta < 0) {
|
|
|
preventDefault(e);
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
e.returnValue = false;
|
|
|
if(box.scrollTop === 0){
|
|
|
if(delta > 0) {
|
|
|
preventDefault(e);
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
// 会阻止原生滚动
|
|
|
// return false;
|
|
|
}
|
|
|
|
|
|
function disableScroll(e) {
|
|
|
function disableScroll() {
|
|
|
var startX, startY;
|
|
|
|
|
|
// older FF
|
|
|
if (window.addEventListener) {
|
|
|
window.addEventListener('DOMMouseScroll', preventDefault, false);
|
|
|
}
|
|
|
var $choseArea = $('.chose-panel .main .chose-items');
|
|
|
|
|
|
// 内部可滚
|
|
|
$choseArea.on('mousewheel', innerScroll);
|
|
|
|
|
|
// 移动端touch重写
|
|
|
$choseArea.on('touchstart', function(e) {
|
|
|
startX = e.originalEvent.changedTouches[0].pageX;
|
|
|
startY = e.originalEvent.changedTouches[0].pageY;
|
|
|
});
|
|
|
|
|
|
window.onwheel = preventDefault; // modern standard
|
|
|
window.onmousewheel = document.onmousewheel = preventDefault; // older browsers, IE
|
|
|
window.ontouchmove = preventDefault; // mobile
|
|
|
// 仿innerScroll方法
|
|
|
$choseArea.on('touchmove', function(e) {
|
|
|
e.stopPropagation();
|
|
|
|
|
|
var deltaX = e.originalEvent.changedTouches[0].pageX - startX;
|
|
|
var deltaY = e.originalEvent.changedTouches[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;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
$(document).on('mousewheel', preventDefault);
|
|
|
$(document).on('touchmove', preventDefault);
|
|
|
}
|
|
|
|
|
|
function enableScroll() {
|
|
|
if (window.removeEventListener) {
|
|
|
window.removeEventListener('DOMMouseScroll', preventDefault, false);
|
|
|
}
|
|
|
window.onmousewheel = document.onmousewheel = null;
|
|
|
window.onwheel = null;
|
|
|
window.ontouchmove = null;
|
|
|
document.onkeydown = null;
|
|
|
var $choseArea = $('.chose-panel .main .chose-items');
|
|
|
|
|
|
$choseArea.off('touchstart');
|
|
|
$choseArea.off('touchmove');
|
|
|
$choseArea.off('mousewheel');
|
|
|
|
|
|
$(document).off('mousewheel', preventDefault);
|
|
|
$(document).off('touchmove', preventDefault);
|
|
|
}
|
|
|
|
|
|
//删除面板
|
...
|
...
|
@@ -159,10 +214,12 @@ function show(html, cb) { |
|
|
}
|
|
|
init();
|
|
|
}
|
|
|
|
|
|
$('.chose-panel').show();
|
|
|
$num = $('#good-num');
|
|
|
cbFn = cb;
|
|
|
|
|
|
|
|
|
disableScroll();
|
|
|
}
|
|
|
|
...
|
...
|
|