Authored by ccbikai

star 首页优化

... ... @@ -15,6 +15,16 @@
<a class="rank-avatar" href='{{url}}' data-avatar="{{image cover 180 180}}"></a>
</li>
{{/ starAvatar}}
{{# starAvatar}}
<li class="swiper-slide">
<a class="rank-avatar" href='{{url}}' data-avatar="{{image cover 180 180}}"></a>
</li>
{{/ starAvatar}}
{{# starAvatar}}
<li class="swiper-slide">
<a class="rank-avatar" href='{{url}}' data-avatar="{{image cover 180 180}}"></a>
</li>
{{/ starAvatar}}
</ul>
</div>
</div>
... ...
... ... @@ -14,7 +14,8 @@ var $ = require('yoho-jquery'),
var $window = $(window),
$starArticle = $('.star-article'),
$headTab = $('.head-tab'),
// $headTab = $('.head-tab'),
stopLoading = false,
avatarSwiper,
avatarSwiperClone,
... ... @@ -71,12 +72,11 @@ function setIndexAction() {
var commonHeaderTop = $('#yoho-header').outerHeight(),
$loadingTip = $('.loading-tip'),
$avatarWrap = $('.avatar-wrap:not(.avatar-clone)'),
avatarHeight = $('.avatar').height(),
infoTop = $('.star-info').css('margin-top');
avatarHeight = $('.avatar').height();
// 下拉刷新,上拉加载
starIScroll = new PullRefresh('.star-wrap', {
height: $(window).height() - commonHeaderTop - avatarHeight - parseInt(infoTop, 10) * 2,
height: $(window).height() - commonHeaderTop - avatarHeight,
pullDown: function() {
if (!stopLoading) {
stopLoading = true;
... ... @@ -93,7 +93,8 @@ function setIndexAction() {
starIScroll.iScroll.on('scrollStart', function() {
// 下拉
if (this.directionY === -1) {
$headTab.slideDown();
// $headTab.slideDown();
$loadingTip.slideDown();
}
});
... ... @@ -127,9 +128,9 @@ function setIndexAction() {
starIScroll.iScroll.on('scrollEnd', function() {
// 上滑
if (this.directionY === 1) {
$headTab.slideUp(600);
}
// if (this.directionY === 1) {
// $headTab.slideUp(600);
// }
$loadingTip.slideUp();
});
... ... @@ -195,20 +196,6 @@ function setIndexAction() {
$(item).addClass('avatar-' + key);
});
// banner swiper 初始化
if ($('.banner-swiper').find('li').length > 1) {
new Swiper('.banner-swiper', {
lazyLoading: true,
lazyLoadingInPrevNext: true,
loop: true,
autoplay: 3000,
autoplayDisableOnInteraction: false,
paginationClickable: true,
slideElement: 'li',
pagination: '.banner-top .pagination-inner'
});
}
// 明星头像 swiper 初始化
if (bannerLen > 1) {
avatarSwiper = new Swiper('.avatar-1', {
... ... @@ -234,6 +221,19 @@ function setIndexAction() {
});
}
// banner swiper 初始化
if ($('.banner-swiper').find('li').length > 1) {
new Swiper('.banner-swiper', {
lazyLoading: true,
lazyLoadingInPrevNext: true,
loop: true,
autoplay: 3000,
autoplayDisableOnInteraction: false,
paginationClickable: true,
slideElement: 'li',
pagination: '.banner-top .pagination-inner'
});
}
if ($('.star-info').find('li').length > 0) {
$starArticle.each(function(key, item) {
... ... @@ -249,14 +249,14 @@ function setIndexAction() {
avatarKey = $(this).index();
if (avatarKey >= (2 * bannerLen + 1)) {
avatarSwiperClone && avatarSwiperClone.slideTo(bannerLen + 1, 0);
avatarSwiper.slideTo(bannerLen + 1, 0);
avatarSwiperClone && avatarSwiperClone.slideTo(bannerLen + 1, 200);
avatarSwiper.slideTo(bannerLen + 1, 200);
} else if (avatarKey <= (bannerLen - 1)) {
avatarSwiperClone && avatarSwiperClone.slideTo(2 * bannerLen - 1, 0);
avatarSwiper.slideTo(2 * bannerLen - 1, 0);
avatarSwiperClone && avatarSwiperClone.slideTo(2 * bannerLen - 1, 200);
avatarSwiper.slideTo(2 * bannerLen - 1, 200);
} else {
avatarSwiperClone && avatarSwiperClone.slideTo(avatarKey, 0);
avatarSwiper.slideTo(avatarKey, 0);
avatarSwiperClone && avatarSwiperClone.slideTo(avatarKey, 200);
avatarSwiper.slideTo(avatarKey, 200);
}
return false;
... ... @@ -294,7 +294,7 @@ getIndexHtml = function() {
$starMain.html(data);
bannerLen = $('.avatar .swiper-slide').length;
if ($('.avatar-clone')) {
if ($('.avatar-clone').length) {
$('.avatar-clone').remove();
}
... ... @@ -309,11 +309,11 @@ getIndexHtml = function() {
txtLimit($(this), '.title', '.cont-txt');
});
loading.hideLoadingMask();
lazyLoad($('img.lazy'));
setTimeout(function() {
setIndexAction();
loading.hideLoadingMask();
}, 100);
},
... ...