Authored by hongweigao

品类顶部固定

... ... @@ -91,7 +91,7 @@
{{#newProduct}}
<div id="new-product-floor" class="newProduct-floor">
{{> common/floor-header}}
<div class="all-catagory clearfix">
<div class="all-catagory fixed-area clearfix">
<div class="catagory-text">推荐品类</div>
<ul class="catagory-navs clearfix">
{{#ctyList}}
... ...
... ... @@ -8,6 +8,8 @@ var Swiper = require('yoho-swiper');
var yas = require('../common/data-yas');
var $arriveList = $('.new-arrive-list');
var $goodInfo = $arriveList.find('.good-info');
var $fixedArea = $('.fixed-area');
var fixedAreaTop = $fixedArea.offset() ? $fixedArea.offset().top : 0;
require('../common');
require('../plugins/slider');
... ... @@ -97,6 +99,20 @@ function getProData($good) {
return goodObj;
}
function fixAreaTop(scrollTop) {
if (scrollTop > fixedAreaTop) {
$fixedArea.css({
position: 'fixed',
top: 0
});
} else {
$fixedArea.css({
position: 'static',
top: 0
});
}
}
new Swiper('.rec-swiper', {
pagination: '.swiper-pagination',
paginationClickable: true,
... ... @@ -122,6 +138,12 @@ lazyLoad($('img.lazy'));
require('./detail/latest-walk'); // 最近浏览
$(window).on('scroll', function() {
var scrollTop = $(this).scrollTop();
fixAreaTop(scrollTop);
});
$(document).pjax('.foot-pager .pager > a, .catagory-navs li.active > a', '#pjax-container', {
timeout: 2000
});
... ... @@ -176,6 +198,8 @@ $(function() {
if (brandNum <= 6) {
$brandSwiper.find('.prev,.next').addClass('hide');
}
fixAreaTop($(this).scrollTop());
});
$(function() {
... ... @@ -220,7 +244,7 @@ $(function() {
LIST: getProListData()
}]
};
$bannerSlider.each(function() {
var $a = $(this),
index = $a.parent().index();
... ...
... ... @@ -134,7 +134,8 @@
line-height: 40px;
font-size: 14px;
background: #fff;
z-index: 11;
z-index: 999;
z-index: 999;
.catagory-text {
float: left;
... ... @@ -147,7 +148,7 @@
.catagory-navs {
float: left;
width: 1065px;
width: 1068px;
height: 40px;
overflow: hidden;
}
... ...