Showing
1 changed file
with
17 additions
and
8 deletions
@@ -13,18 +13,26 @@ exports.init = function() { | @@ -13,18 +13,26 @@ exports.init = function() { | ||
13 | var container = $('.article-type-three'), | 13 | var container = $('.article-type-three'), |
14 | thumbContainer = container.find('.thumb-container'), | 14 | thumbContainer = container.find('.thumb-container'), |
15 | prodList = container.find('.prod-list'), | 15 | prodList = container.find('.prod-list'), |
16 | - curItem, prevItem; | 16 | + curItem, //当前focus搭配项 |
17 | + prevItem, //上一次focus的搭配项 | ||
18 | + curList, //当前focus搭配项对应推荐列表 | ||
19 | + prevList; //上一次focus的搭配项对应的列表 | ||
17 | 20 | ||
18 | //点击分类,显示分类下推荐商品列表 | 21 | //点击分类,显示分类下推荐商品列表 |
19 | thumbContainer.delegate('li', 'click', function() { | 22 | thumbContainer.delegate('li', 'click', function() { |
20 | - var index = $(this).index(); | ||
21 | - | ||
22 | - curItem = prodList.find('.prod:eq(' + index + ')').removeClass('hide'); | 23 | + var index; |
24 | + curItem = $(this).addClass('focus'); | ||
25 | + index = curItem.index(); | ||
23 | if (prevItem) { | 26 | if (prevItem) { |
24 | - prevItem.addClass('hide'); | ||
25 | - } else { | ||
26 | - prevItem = curItem; | 27 | + prevItem.removeClass('focus'); |
28 | + } | ||
29 | + prevItem = curItem; | ||
30 | + | ||
31 | + curList = prodList.find('.prod:eq(' + index + ')').removeClass('hide'); | ||
32 | + if (prevList) { | ||
33 | + prevList.addClass('hide'); | ||
27 | } | 34 | } |
35 | + prevList = curList; | ||
28 | }); | 36 | }); |
29 | 37 | ||
30 | //默认选中第一个 | 38 | //默认选中第一个 |
@@ -33,7 +41,8 @@ exports.init = function() { | @@ -33,7 +41,8 @@ exports.init = function() { | ||
33 | //scroll时控制列表的位置 | 41 | //scroll时控制列表的位置 |
34 | $(document).scroll(function() { | 42 | $(document).scroll(function() { |
35 | var sTop = $(this).scrollTop(), | 43 | var sTop = $(this).scrollTop(), |
36 | - cur, parent; | 44 | + cur, |
45 | + parent; | ||
37 | thumbContainer.each(function() { | 46 | thumbContainer.each(function() { |
38 | var pNode = $(this).parent('.article-type-three'); | 47 | var pNode = $(this).parent('.article-type-three'); |
39 | if (sTop > pNode.offset().top) { | 48 | if (sTop > pNode.offset().top) { |
-
Please register or login to post a comment