...
|
...
|
@@ -13,6 +13,8 @@ var $ = require('jquery'), |
|
|
tip = require('../plugin/tip'),
|
|
|
loading = require('../plugin/loading');
|
|
|
|
|
|
var innerScroll = require('../plugin/inner-scroll');
|
|
|
|
|
|
var $chosePanel = $('#chose-panel'),
|
|
|
$num,
|
|
|
$chosed,
|
...
|
...
|
@@ -31,6 +33,7 @@ var $chosePanel = $('#chose-panel'), |
|
|
cbFn,
|
|
|
$allChoseItems,
|
|
|
queryString,
|
|
|
$choseArea,
|
|
|
$soonSoldOut = $('.soonSoldOut-tag'),
|
|
|
$yohoPage = $('.yoho-page');
|
|
|
|
...
|
...
|
@@ -46,6 +49,7 @@ function init() { |
|
|
$curSizeBlock = null;
|
|
|
queryString = $.queryString();
|
|
|
$imgsThumb = $('.chose-panel').find('.thumb');
|
|
|
$choseArea = $('.chose-panel .main .chose-items');
|
|
|
$allChoseItems = $('.chose-items');
|
|
|
$sizeRowList = $('.size-list ul');
|
|
|
$colorRowList = $('.color-list ul');
|
...
|
...
|
@@ -71,101 +75,6 @@ function setEditModeWithSknId(sknId, isThisGoodSelected) { |
|
|
isSelected = isThisGoodSelected;
|
|
|
}
|
|
|
|
|
|
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) {
|
|
|
var delta = e.wheelDelta || e.originalEvent.wheelDelta || e.detail || 0,
|
|
|
box = $(this).get(0);
|
|
|
|
|
|
// 阻止冒泡到document
|
|
|
// document上已经preventDefault
|
|
|
stopPropagation(e);
|
|
|
|
|
|
|
|
|
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;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function disableScroll() {
|
|
|
var startX, startY;
|
|
|
|
|
|
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;
|
|
|
});
|
|
|
|
|
|
// 仿innerScroll方法
|
|
|
$choseArea.on('touchmove', function(e) {
|
|
|
var deltaX = e.originalEvent.changedTouches[0].pageX - startX,
|
|
|
deltaY = e.originalEvent.changedTouches[0].pageY - startY;
|
|
|
|
|
|
var box = $(this).get(0);
|
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
|
|
|
|
// 只能纵向滚
|
|
|
if (Math.abs(deltaY) < Math.abs(deltaX)) {
|
|
|
e.preventDefault();
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
|
|
|
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() {
|
|
|
var $choseArea = $('.chose-panel .main .chose-items');
|
|
|
|
|
|
$choseArea.off('touchstart');
|
|
|
$choseArea.off('touchmove');
|
|
|
$choseArea.off('mousewheel');
|
|
|
|
|
|
$(document).off('mousewheel', preventDefault);
|
|
|
$(document).off('touchmove', preventDefault);
|
|
|
}
|
|
|
|
|
|
//删除面板
|
|
|
function removePannel() {
|
|
|
var $pannel = $('.chose-panel'),
|
...
|
...
|
@@ -220,13 +129,13 @@ function show(html, cb) { |
|
|
cbFn = cb;
|
|
|
|
|
|
|
|
|
disableScroll();
|
|
|
innerScroll.disableScroll($choseArea);
|
|
|
}
|
|
|
|
|
|
//隐藏当前Panel
|
|
|
function hide() {
|
|
|
$('.chose-panel').hide();
|
|
|
enableScroll();
|
|
|
innerScroll.enableScroll($choseArea);
|
|
|
}
|
|
|
|
|
|
//修改加入购物车的文字和背景
|
...
|
...
|
|