...
|
...
|
@@ -15,7 +15,11 @@ var $goodsContainer = $('.goods-container'), |
|
|
|
|
|
var MouseOver = productEvent($goodItem, 5);
|
|
|
|
|
|
// 构造html
|
|
|
/**
|
|
|
* @description 构造商品颜色列表的html结构
|
|
|
* @param data 商品颜色的数组,[url: '',src: '']
|
|
|
* @return json {'colorListStr': '', 'ulNum': ''}
|
|
|
* */
|
|
|
function createColorList(data) {
|
|
|
var colorListStr = '',
|
|
|
len = data.length,
|
...
|
...
|
@@ -49,13 +53,20 @@ function createColorList(data) { |
|
|
if (ulNum < col) {
|
|
|
colorListStr += '</ul>';
|
|
|
}
|
|
|
return colorListStr;
|
|
|
return {
|
|
|
colorListStr: colorListStr,
|
|
|
ulNum: col
|
|
|
};
|
|
|
}
|
|
|
|
|
|
MouseOver.addHandler('MouseEnter', function(event) {
|
|
|
|
|
|
var itemMr = 10, //list的右边距
|
|
|
itemMb = 35, //list的下边距
|
|
|
ulStr = '',
|
|
|
ulNum,
|
|
|
wrapperWidth,
|
|
|
diffWidth,
|
|
|
wrapperX = (event.targetX - 1) * (event.targetWidth + itemMr) - 21,
|
|
|
wrapperY = (event.targetY - 1) * (event.targetHeight + itemMb) + 25 - 19;
|
|
|
|
...
|
...
|
@@ -70,14 +81,25 @@ MouseOver.addHandler('MouseEnter', function(event) { |
|
|
dataType: 'json'
|
|
|
}).then(function(data) {
|
|
|
|
|
|
ulStr = createColorList(data).colorListStr;
|
|
|
ulNum = createColorList(data).ulNum;
|
|
|
|
|
|
$goodInfoMain.append(event.targetDuplicate);
|
|
|
$goodSelectColor.append($(createColorList(data)));
|
|
|
});
|
|
|
$goodSelectColor.append($(ulStr));
|
|
|
wrapperWidth = 10 + (15 + 50) * ulNum + event.targetWidth;
|
|
|
|
|
|
//
|
|
|
diffWidth = event.offsetR - ((15 + 50) * ulNum + 25);
|
|
|
if (diffWidth <= 0) {
|
|
|
wrapperX = wrapperX + diffWidth;
|
|
|
}
|
|
|
$goodItemWrapper.css({
|
|
|
width: wrapperWidth,
|
|
|
left: wrapperX,
|
|
|
top: wrapperY,
|
|
|
display: 'inline-block'
|
|
|
});
|
|
|
|
|
|
$goodItemWrapper.css({
|
|
|
left: wrapperX,
|
|
|
top: wrapperY,
|
|
|
display: 'inline-block'
|
|
|
});
|
|
|
});
|
|
|
|
...
|
...
|
|