|
@@ -15,7 +15,11 @@ var $goodsContainer = $('.goods-container'), |
|
@@ -15,7 +15,11 @@ var $goodsContainer = $('.goods-container'), |
15
|
|
15
|
|
16
|
var MouseOver = productEvent($goodItem, 5);
|
16
|
var MouseOver = productEvent($goodItem, 5);
|
17
|
|
17
|
|
18
|
-// 构造html
|
18
|
+/**
|
|
|
19
|
+ * @description 构造商品颜色列表的html结构
|
|
|
20
|
+ * @param data 商品颜色的数组,[url: '',src: '']
|
|
|
21
|
+ * @return json {'colorListStr': '', 'ulNum': ''}
|
|
|
22
|
+ * */
|
19
|
function createColorList(data) {
|
23
|
function createColorList(data) {
|
20
|
var colorListStr = '',
|
24
|
var colorListStr = '',
|
21
|
len = data.length,
|
25
|
len = data.length,
|
|
@@ -49,13 +53,20 @@ function createColorList(data) { |
|
@@ -49,13 +53,20 @@ function createColorList(data) { |
49
|
if (ulNum < col) {
|
53
|
if (ulNum < col) {
|
50
|
colorListStr += '</ul>';
|
54
|
colorListStr += '</ul>';
|
51
|
}
|
55
|
}
|
52
|
- return colorListStr;
|
56
|
+ return {
|
|
|
57
|
+ colorListStr: colorListStr,
|
|
|
58
|
+ ulNum: col
|
|
|
59
|
+ };
|
53
|
}
|
60
|
}
|
54
|
|
61
|
|
55
|
MouseOver.addHandler('MouseEnter', function(event) {
|
62
|
MouseOver.addHandler('MouseEnter', function(event) {
|
56
|
|
63
|
|
57
|
var itemMr = 10, //list的右边距
|
64
|
var itemMr = 10, //list的右边距
|
58
|
itemMb = 35, //list的下边距
|
65
|
itemMb = 35, //list的下边距
|
|
|
66
|
+ ulStr = '',
|
|
|
67
|
+ ulNum,
|
|
|
68
|
+ wrapperWidth,
|
|
|
69
|
+ diffWidth,
|
59
|
wrapperX = (event.targetX - 1) * (event.targetWidth + itemMr) - 21,
|
70
|
wrapperX = (event.targetX - 1) * (event.targetWidth + itemMr) - 21,
|
60
|
wrapperY = (event.targetY - 1) * (event.targetHeight + itemMb) + 25 - 19;
|
71
|
wrapperY = (event.targetY - 1) * (event.targetHeight + itemMb) + 25 - 19;
|
61
|
|
72
|
|
|
@@ -70,14 +81,25 @@ MouseOver.addHandler('MouseEnter', function(event) { |
|
@@ -70,14 +81,25 @@ MouseOver.addHandler('MouseEnter', function(event) { |
70
|
dataType: 'json'
|
81
|
dataType: 'json'
|
71
|
}).then(function(data) {
|
82
|
}).then(function(data) {
|
72
|
|
83
|
|
|
|
84
|
+ ulStr = createColorList(data).colorListStr;
|
|
|
85
|
+ ulNum = createColorList(data).ulNum;
|
|
|
86
|
+
|
73
|
$goodInfoMain.append(event.targetDuplicate);
|
87
|
$goodInfoMain.append(event.targetDuplicate);
|
74
|
- $goodSelectColor.append($(createColorList(data)));
|
|
|
75
|
- });
|
88
|
+ $goodSelectColor.append($(ulStr));
|
|
|
89
|
+ wrapperWidth = 10 + (15 + 50) * ulNum + event.targetWidth;
|
|
|
90
|
+
|
|
|
91
|
+ //
|
|
|
92
|
+ diffWidth = event.offsetR - ((15 + 50) * ulNum + 25);
|
|
|
93
|
+ if (diffWidth <= 0) {
|
|
|
94
|
+ wrapperX = wrapperX + diffWidth;
|
|
|
95
|
+ }
|
|
|
96
|
+ $goodItemWrapper.css({
|
|
|
97
|
+ width: wrapperWidth,
|
|
|
98
|
+ left: wrapperX,
|
|
|
99
|
+ top: wrapperY,
|
|
|
100
|
+ display: 'inline-block'
|
|
|
101
|
+ });
|
76
|
|
102
|
|
77
|
- $goodItemWrapper.css({
|
|
|
78
|
- left: wrapperX,
|
|
|
79
|
- top: wrapperY,
|
|
|
80
|
- display: 'inline-block'
|
|
|
81
|
});
|
103
|
});
|
82
|
});
|
104
|
});
|
83
|
|
105
|
|