...
|
...
|
@@ -16,7 +16,8 @@ var $window = $(window), |
|
|
$starArticle = $('.star-article'),
|
|
|
$headTab = $('.head-tab'),
|
|
|
stopLoading = false,
|
|
|
avatarSwiper = [],
|
|
|
avatarSwiper,
|
|
|
avatarSwiperClone,
|
|
|
getIndexHtml;
|
|
|
|
|
|
/*
|
...
|
...
|
@@ -70,12 +71,19 @@ function setIndexAction() { |
|
|
var $loadingTip = $('.loading-tip');
|
|
|
var $avatarWrap = $('.avatar-wrap');
|
|
|
|
|
|
var move;
|
|
|
|
|
|
// 下拉刷新,上拉加载
|
|
|
starIScroll = new PullRefresh('.star-wrap', {
|
|
|
height: $(window).height() - commonHeaderTop,
|
|
|
pullDown: function() {
|
|
|
if (!stopLoading) {
|
|
|
stopLoading = true;
|
|
|
|
|
|
if (avatarSwiperClone) {
|
|
|
avatarSwiperClone.destroy(true, true);
|
|
|
avatarSwiperClone = '';
|
|
|
}
|
|
|
getIndexHtml();
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -91,11 +99,27 @@ function setIndexAction() { |
|
|
|
|
|
starIScroll.iScroll.on('scroll', function() {
|
|
|
if (commonHeaderTop > $avatarWrap.offset().top) {
|
|
|
// $('.avatar-clone').css('top', $('.head-tab').outerHeight());
|
|
|
$('.avatar-clone').show();
|
|
|
starIScroll[0].update();
|
|
|
starIScroll[1].update();
|
|
|
} else {
|
|
|
|
|
|
if (!avatarSwiperClone) {
|
|
|
avatarSwiperClone = new Swiper('.avatar-0', {
|
|
|
loop: true,
|
|
|
initialSlide: $('.avatar-1').find('.swiper-slide-active').index(),
|
|
|
centeredSlides: true,
|
|
|
slidesPerView: 'auto',
|
|
|
loopedSlides: bannerLen,
|
|
|
spaceBetween: 10,
|
|
|
slidesOffsetBefore : -($('.swiper-num').width()),
|
|
|
watchSlidesProgress: true,
|
|
|
watchSlidesVisibility: true
|
|
|
});
|
|
|
|
|
|
avatarSwiperClone.params.control = avatarSwiper;
|
|
|
avatarSwiper.params.control = avatarSwiperClone;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (Math.abs(this.startY) < $('.banner-top').height() + $('.avatar').outerHeight() + $('.head-tab').height()) {
|
|
|
$('.avatar-clone').hide();
|
|
|
}
|
|
|
});
|
...
|
...
|
@@ -105,6 +129,7 @@ function setIndexAction() { |
|
|
if (this.directionY === 1) {
|
|
|
$headTab.slideUp(1000);
|
|
|
}
|
|
|
|
|
|
$loadingTip.slideUp();
|
|
|
});
|
|
|
|
...
|
...
|
@@ -165,6 +190,10 @@ function setIndexAction() { |
|
|
}
|
|
|
*/
|
|
|
|
|
|
$('.avatar').each(function(key, item){
|
|
|
$(item).addClass('avatar-' + key);
|
|
|
});
|
|
|
|
|
|
// banner swiper 初始化
|
|
|
if ($('.banner-swiper').find('li').length > 1) {
|
|
|
new Swiper('.banner-swiper', {
|
...
|
...
|
@@ -180,42 +209,18 @@ function setIndexAction() { |
|
|
}
|
|
|
|
|
|
// 明星头像 swiper 初始化
|
|
|
// if (bannerLen > 1) {
|
|
|
// $('.avatar-swiper').each(function(key, item) {
|
|
|
// avatarSwiper[key] = new Swiper('.avatar-' + key, {
|
|
|
// loop: true,
|
|
|
// // loopedSlides: bannerLen,
|
|
|
// initialSlide: 2,
|
|
|
// centeredSlides: true,
|
|
|
// slidesPerView: 'auto',
|
|
|
// spaceBetween: 10,
|
|
|
// slidesOffsetBefore: '-' + $(item).find('li').not('.swiper-slide-visible').width() / 2,
|
|
|
// watchSlidesProgress: true,
|
|
|
// watchSlidesVisibility: true,
|
|
|
// observer: true,
|
|
|
// observeParents: true
|
|
|
// });
|
|
|
// });
|
|
|
// }
|
|
|
|
|
|
if (bannerLen > 1) {
|
|
|
avatarSwiper = new Swiper('.avatar', {
|
|
|
avatarSwiper = new Swiper('.avatar-1', {
|
|
|
loop: true,
|
|
|
|
|
|
// loopedSlides: bannerLen,
|
|
|
initialSlide: 2,
|
|
|
mode:'horizontal',
|
|
|
centeredSlides: true,
|
|
|
slidesPerView: 'auto',
|
|
|
loopedSlides: bannerLen,
|
|
|
spaceBetween: 10,
|
|
|
slidesOffsetBefore: -($('.avatar').find('li').not('.swiper-slide-visible').width() / 2),
|
|
|
slidesOffsetBefore : -($('.swiper-num').width()),
|
|
|
watchSlidesProgress: true,
|
|
|
watchSlidesVisibility: true,
|
|
|
observer: true,
|
|
|
observeParents: true
|
|
|
});
|
|
|
|
|
|
avatarSwiper[0].params.control = avatarSwiper[1];// 需要在Swiper2初始化后,Swiper1控制Swiper2
|
|
|
avatarSwiper[1].params.control = avatarSwiper[0];// 需要在Swiper1初始化后,Swiper2控制Swiper1
|
|
|
watchSlidesVisibility: true
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 明星动态头像左右滑动
|
...
|
...
|
@@ -238,18 +243,21 @@ function setIndexAction() { |
|
|
});
|
|
|
}
|
|
|
|
|
|
|
|
|
// 明星头像点击居中显示或跳转
|
|
|
$('.avatar-swiper li').on('click', function() {
|
|
|
if ($(this).hasClass('swiper-slide-active')) {
|
|
|
location.href = $(this).find('img').data('url');
|
|
|
} else {
|
|
|
avatarKey = $(this).index();
|
|
|
avatarSwiper[0].slideTo(avatarKey, 1000, false);
|
|
|
|
|
|
if(avatarSwiperClone) {
|
|
|
avatarSwiperClone.slideTo(avatarKey, 1000, false);
|
|
|
}
|
|
|
|
|
|
avatarSwiper.slideTo(avatarKey, 1000, false);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|
|
|
$('.rank-avatar').each(function(key, item) {
|
|
|
if ($(item).attr('data-avatar') !== '') {
|
|
|
setAvatar($(item));
|
...
|
...
|
@@ -276,7 +284,15 @@ getIndexHtml = function() { |
|
|
$starMain.html(data);
|
|
|
bannerLen = $('.avatar .swiper-slide').length;
|
|
|
|
|
|
$starMain.prepend($('.avatar-swiper').clone().addClass('avatar-clone').hide());
|
|
|
if ($('.avatar-clone')) {
|
|
|
$('.avatar-clone').remove();
|
|
|
}
|
|
|
|
|
|
$('.avatar li').each(function(){
|
|
|
setAvatar($(this).find('span'));
|
|
|
});
|
|
|
|
|
|
$starMain.before($('.avatar-swiper').clone().addClass('avatar-clone').hide());
|
|
|
|
|
|
// 限制标题字数
|
|
|
$('.cont-area').each(function() {
|
...
|
...
|
|