Showing
1 changed file
with
17 additions
and
7 deletions
@@ -10,6 +10,7 @@ var $ = require('jquery'), | @@ -10,6 +10,7 @@ var $ = require('jquery'), | ||
10 | lazyLoad = require('yoho.lazyload'); | 10 | lazyLoad = require('yoho.lazyload'); |
11 | 11 | ||
12 | var swiper, | 12 | var swiper, |
13 | + $fixTitleBar, | ||
13 | $brandList = $('.brand-list'); | 14 | $brandList = $('.brand-list'); |
14 | 15 | ||
15 | var searchH = $('.newbrand-search').outerHeight(), | 16 | var searchH = $('.newbrand-search').outerHeight(), |
@@ -38,21 +39,30 @@ $('.yoho-header').css({ | @@ -38,21 +39,30 @@ $('.yoho-header').css({ | ||
38 | top: 0 | 39 | top: 0 |
39 | }); | 40 | }); |
40 | 41 | ||
42 | +$fixTitleBar = $('<div class="title-bar fixed-title-bar"><h2></h2></div>'); | ||
43 | +$fixTitleBar.hide(); | ||
44 | +$('.brand-list').last().append($fixTitleBar); | ||
45 | + | ||
41 | $(window).scroll(function() { | 46 | $(window).scroll(function() { |
42 | - var scrTop = $(window).scrollTop(); | 47 | + var scrTop = $(window).scrollTop(), |
48 | + minBrandListTop = brandSwipe + $('.hot-brand').outerHeight() + | ||
49 | + $('.banner-top').outerHeight(); | ||
50 | + | ||
51 | + if ($brandList.eq(0).offset().top < minBrandListTop) { | ||
52 | + $fixTitleBar.hide(); | ||
53 | + } | ||
43 | 54 | ||
44 | - $('.brand-list').each(function() { | 55 | + $brandList.each(function() { |
45 | var offTop = $(this).offset().top - brandSwipe; | 56 | var offTop = $(this).offset().top - brandSwipe; |
46 | 57 | ||
47 | if (scrTop >= offTop) { | 58 | if (scrTop >= offTop) { |
48 | - $brandList.find('.title-bar').css('position', 'static'); | ||
49 | - $(this).find('.title-bar').css({ | 59 | + $fixTitleBar.css({ |
60 | + display: 'block', | ||
50 | position: 'fixed', | 61 | position: 'fixed', |
51 | top: brandSwipe | 62 | top: brandSwipe |
52 | - }); | ||
53 | - } else { | ||
54 | - $(this).find('.title-bar').css('position', 'static'); | 63 | + }).find('h2').html($(this).find('.title-bar').text()); |
55 | } | 64 | } |
65 | + | ||
56 | }); | 66 | }); |
57 | }); | 67 | }); |
58 | 68 |
-
Please register or login to post a comment