Showing
1 changed file
with
38 additions
and
16 deletions
@@ -6,7 +6,14 @@ var categoryHeight = $('.tab-box').height(), | @@ -6,7 +6,14 @@ var categoryHeight = $('.tab-box').height(), | ||
6 | 6 | ||
7 | var $intercept = $('.no-intercept'), | 7 | var $intercept = $('.no-intercept'), |
8 | $list = $('.brand-list-box'), | 8 | $list = $('.brand-list-box'), |
9 | - $listBox = $('.list-box'); | 9 | + $listBox = $('.list-box'), |
10 | + $brandContent = $('.brand-content'), | ||
11 | + $tabBox = $('.tab-box'), | ||
12 | + $contentIndex = $('.content-index'), | ||
13 | + $categoryNav = $('.category-nav'), | ||
14 | + $channelTab = $('.channel-tab'), | ||
15 | + $categoryContent = $('.category-content'), | ||
16 | + $brandCha = $('.brand-cha'); | ||
10 | 17 | ||
11 | require('../common'); | 18 | require('../common'); |
12 | require('./brand-cate/cate-all'); | 19 | require('./brand-cate/cate-all'); |
@@ -48,14 +55,14 @@ function loadData(channel) { | @@ -48,14 +55,14 @@ function loadData(channel) { | ||
48 | gender: channel | 55 | gender: channel |
49 | }, | 56 | }, |
50 | success: function(data) { | 57 | success: function(data) { |
51 | - $('.brand-content').html(data); | 58 | + $brandContent.html(data); |
52 | 59 | ||
53 | initialize(); | 60 | initialize(); |
54 | } | 61 | } |
55 | }); | 62 | }); |
56 | } | 63 | } |
57 | 64 | ||
58 | -$('.brand-cha').find('li').click(function() { | 65 | +$brandCha.find('li').click(function() { |
59 | gender = $(this).find('span').text().replace(/[^A-Za-z]+/g, '').toLowerCase(); | 66 | gender = $(this).find('span').text().replace(/[^A-Za-z]+/g, '').toLowerCase(); |
60 | 67 | ||
61 | $(this).addClass('focus').siblings().removeClass('focus'); | 68 | $(this).addClass('focus').siblings().removeClass('focus'); |
@@ -79,15 +86,30 @@ $('.brand-tab').find('li').click(function() { | @@ -79,15 +86,30 @@ $('.brand-tab').find('li').click(function() { | ||
79 | $(this).addClass('active').siblings().removeClass('active'); | 86 | $(this).addClass('active').siblings().removeClass('active'); |
80 | 87 | ||
81 | if ($(this).hasClass('brand')) { | 88 | if ($(this).hasClass('brand')) { |
82 | - $('.brand-content').removeClass('hide').siblings().addClass('hide'); | ||
83 | - $('.channel-tab').removeClass('hide'); | ||
84 | - $('.brand-cha').removeClass('hide').siblings().addClass('hide'); | 89 | + $brandContent.removeClass('hide').siblings().addClass('hide'); |
90 | + $channelTab.removeClass('hide'); | ||
91 | + $brandCha.removeClass('hide').siblings().addClass('hide'); | ||
85 | } else { | 92 | } else { |
86 | - $('.category-content').removeClass('hide').siblings().addClass('hide'); | 93 | + $categoryContent.removeClass('hide').siblings().addClass('hide'); |
87 | $('.channel-tab').addClass('hide'); | 94 | $('.channel-tab').addClass('hide'); |
88 | } | 95 | } |
89 | 96 | ||
90 | initialize(); | 97 | initialize(); |
98 | + | ||
99 | + //页面切换回到头部 | ||
100 | + $('html,body').animate({ | ||
101 | + scrollTop: 0 | ||
102 | + }, 100, function() { | ||
103 | + if (!$brandContent.hasClass('hide')) { | ||
104 | + $tabBox.removeClass('fastening'); | ||
105 | + $contentIndex.removeClass('distance'); | ||
106 | + } else { | ||
107 | + $tabBox.removeClass('fastening'); | ||
108 | + $categoryNav.removeClass('loca'); | ||
109 | + $('.blk-cate-all .content').removeClass('living'); | ||
110 | + $contentIndex.removeClass('distance'); | ||
111 | + } | ||
112 | + }); | ||
91 | }); | 113 | }); |
92 | 114 | ||
93 | if ($listBox.find('li').length <= 0) { | 115 | if ($listBox.find('li').length <= 0) { |
@@ -97,24 +119,24 @@ if ($listBox.find('li').length <= 0) { | @@ -97,24 +119,24 @@ if ($listBox.find('li').length <= 0) { | ||
97 | $(window).scroll(function() { | 119 | $(window).scroll(function() { |
98 | var totalHeight = $('#yoho-header').height() + $('.tab-box').height(); | 120 | var totalHeight = $('#yoho-header').height() + $('.tab-box').height(); |
99 | 121 | ||
100 | - if (!$('.brand-content').hasClass('hide')) { | 122 | + if (!$brandContent.hasClass('hide')) { |
101 | if ($(this).scrollTop() >= $('#yoho-header').height()) { | 123 | if ($(this).scrollTop() >= $('#yoho-header').height()) { |
102 | - $('.tab-box').addClass('fastening'); | ||
103 | - $('.content-index').addClass('distance'); | 124 | + $tabBox.addClass('fastening'); |
125 | + $contentIndex.addClass('distance'); | ||
104 | $('.list-box').css('top', $('.tab-box').height()); | 126 | $('.list-box').css('top', $('.tab-box').height()); |
105 | } else { | 127 | } else { |
106 | - $('.tab-box').removeClass('fastening'); | ||
107 | - $('.content-index').removeClass('distance'); | 128 | + $tabBox.removeClass('fastening'); |
129 | + $contentIndex.removeClass('distance'); | ||
108 | $('.list-box').css('top', totalHeight - $(this).scrollTop()); | 130 | $('.list-box').css('top', totalHeight - $(this).scrollTop()); |
109 | } | 131 | } |
110 | } else { | 132 | } else { |
111 | if ($(this).scrollTop() >= $('#yoho-header').height()) { | 133 | if ($(this).scrollTop() >= $('#yoho-header').height()) { |
112 | - $('.tab-box').addClass('fastening'); | ||
113 | - $('.category-nav').addClass('loca'); | 134 | + $tabBox.addClass('fastening'); |
135 | + $categoryNav.addClass('loca'); | ||
114 | $('.blk-cate-all .content').addClass('living'); | 136 | $('.blk-cate-all .content').addClass('living'); |
115 | } else { | 137 | } else { |
116 | - $('.tab-box').removeClass('fastening'); | ||
117 | - $('.category-nav').removeClass('loca'); | 138 | + $tabBox.removeClass('fastening'); |
139 | + $categoryNav.removeClass('loca'); | ||
118 | $('.blk-cate-all .content').removeClass('living'); | 140 | $('.blk-cate-all .content').removeClass('living'); |
119 | } | 141 | } |
120 | } | 142 | } |
-
Please register or login to post a comment