Showing
1 changed file
with
24 additions
and
11 deletions
@@ -15,18 +15,10 @@ var mySwiper; | @@ -15,18 +15,10 @@ var mySwiper; | ||
15 | 15 | ||
16 | lazyLoad($('img.lazy')); | 16 | lazyLoad($('img.lazy')); |
17 | 17 | ||
18 | -$contents.find('li').each(function(key, item) { | ||
19 | - $(item).find('.swiper-container').addClass('swiper-' + key); | ||
20 | - | ||
21 | - mySwiper = new Swiper('.swiper-' + key, { | ||
22 | - lazyLoading: true, | ||
23 | - pagination: '.swiper-' + key + ' .pagination-inner' | ||
24 | - }); | ||
25 | -}); | ||
26 | - | ||
27 | $('#nav-tab').bind('contextmenu', function(e) { | 18 | $('#nav-tab').bind('contextmenu', function(e) { |
28 | return false; | 19 | return false; |
29 | }); | 20 | }); |
21 | + | ||
30 | $('#nav-tab').on('touchend touchcancel', function(e) { | 22 | $('#nav-tab').on('touchend touchcancel', function(e) { |
31 | var $this = $(e.target).closest('li'); | 23 | var $this = $(e.target).closest('li'); |
32 | 24 | ||
@@ -34,11 +26,32 @@ $('#nav-tab').on('touchend touchcancel', function(e) { | @@ -34,11 +26,32 @@ $('#nav-tab').on('touchend touchcancel', function(e) { | ||
34 | return; | 26 | return; |
35 | } | 27 | } |
36 | 28 | ||
37 | - $navs.toggleClass('focus'); | ||
38 | - $contents.toggleClass('hide'); | 29 | + $navs.removeClass('focus'); |
30 | + $this.addClass('focus'); | ||
31 | + $contents.addClass('hide'); | ||
32 | + $contents.eq($this.index()).removeClass('hide'); | ||
33 | + | ||
34 | + if (typeof $this.swiper === 'undefined') {//解决隐藏式,swiper不渲染 | ||
35 | + $this.swiper = false; | ||
36 | + $contents.find('li').each(function(key, item) { | ||
37 | + $(item).find('.swiper-container').addClass('swiper-' + key); | ||
38 | + | ||
39 | + mySwiper = new Swiper('.swiper-' + key, { | ||
40 | + lazyLoading: true, | ||
41 | + pagination: '.swiper-' + key + ' .pagination-inner' | ||
42 | + }); | ||
43 | + }); | ||
44 | + } | ||
39 | 45 | ||
40 | $(document).trigger('scroll'); //Trigger lazyLoad | 46 | $(document).trigger('scroll'); //Trigger lazyLoad |
41 | }); | 47 | }); |
48 | + | ||
49 | +if ($('#nav-tab').find('li:eq(0)').hasClass('focus')) { | ||
50 | + //解决li隐藏 swiper不渲染的问题 | ||
51 | + $('#nav-tab').find('li:eq(0)').removeClass('focus'); | ||
52 | + $('#nav-tab').find('li:eq(0)').trigger('touchend'); | ||
53 | +} | ||
54 | + | ||
42 | $('#nav-tab').on('touchstart', function(e) { | 55 | $('#nav-tab').on('touchstart', function(e) { |
43 | var target = e.target || e.srcElement; | 56 | var target = e.target || e.srcElement; |
44 | 57 |
-
Please register or login to post a comment