Showing
1 changed file
with
18 additions
and
6 deletions
@@ -189,6 +189,8 @@ function shopNavData() { | @@ -189,6 +189,8 @@ function shopNavData() { | ||
189 | navList: data | 189 | navList: data |
190 | }); | 190 | }); |
191 | 191 | ||
192 | + var tabNum; | ||
193 | + | ||
192 | if (data === false) { | 194 | if (data === false) { |
193 | shopListData('null'); | 195 | shopListData('null'); |
194 | $('.shop-nav').hide(); | 196 | $('.shop-nav').hide(); |
@@ -198,12 +200,7 @@ function shopNavData() { | @@ -198,12 +200,7 @@ function shopNavData() { | ||
198 | 200 | ||
199 | $('.shop-area').html(navString); | 201 | $('.shop-area').html(navString); |
200 | 202 | ||
201 | - // 导航滑动效果 | ||
202 | - navSwiper = new Swiper('.shop-area', { | ||
203 | - grabCursor: true, | ||
204 | - slidesPerView: 'auto', | ||
205 | - slideElement: 'li' | ||
206 | - }); | 203 | + |
207 | 204 | ||
208 | // 加载第一页数据 | 205 | // 加载第一页数据 |
209 | if (navType.id) { | 206 | if (navType.id) { |
@@ -211,6 +208,7 @@ function shopNavData() { | @@ -211,6 +208,7 @@ function shopNavData() { | ||
211 | if (decodeURI(navType.id) === $(this).data('type')) { | 208 | if (decodeURI(navType.id) === $(this).data('type')) { |
212 | $(this).addClass('active'); | 209 | $(this).addClass('active'); |
213 | shopListData($(this).data('type')); | 210 | shopListData($(this).data('type')); |
211 | + tabNum = $(this).index(); | ||
214 | } | 212 | } |
215 | }); | 213 | }); |
216 | } else { | 214 | } else { |
@@ -218,6 +216,20 @@ function shopNavData() { | @@ -218,6 +216,20 @@ function shopNavData() { | ||
218 | shopListData($('.shop-nav').find('li').eq(0).data('type')); | 216 | shopListData($('.shop-nav').find('li').eq(0).data('type')); |
219 | } | 217 | } |
220 | 218 | ||
219 | + // 导航滑动效果 | ||
220 | + navSwiper = new Swiper('.shop-area', { | ||
221 | + grabCursor: true, | ||
222 | + slidesPerView: 'auto', | ||
223 | + initialSlide: tabNum, | ||
224 | + slideElement: 'li' | ||
225 | + }); | ||
226 | + | ||
227 | + if (tabNum < 3) { | ||
228 | + $('.shop-area ul').css({ | ||
229 | + transform: 'translateX(0px)' | ||
230 | + }); | ||
231 | + } | ||
232 | + | ||
221 | $(window).on('scroll touchmove touchstart touchend', function() { | 233 | $(window).on('scroll touchmove touchstart touchend', function() { |
222 | if ($(window).scrollTop() > $('.shop-nav')[0].offsetTop) { | 234 | if ($(window).scrollTop() > $('.shop-nav')[0].offsetTop) { |
223 | $('.shop-area').addClass('fixer'); | 235 | $('.shop-area').addClass('fixer'); |
-
Please register or login to post a comment