...
|
...
|
@@ -14,10 +14,11 @@ var $ = require('yoho-jquery'), |
|
|
|
|
|
var $window = $(window),
|
|
|
stopLoading = false,
|
|
|
$starMain = $('.star-main'),
|
|
|
$mainContent = $('.main-content'),
|
|
|
$headTab = $('.head-tab'),
|
|
|
headTabH = $headTab.height(),
|
|
|
scrollH = $(window).height() - headTabH;
|
|
|
scrollH = $(window).height() - headTabH,
|
|
|
$loadingTip = $('.loading-tip');
|
|
|
|
|
|
/*
|
|
|
$swiperView = $('.swiper-view'),
|
...
|
...
|
@@ -29,7 +30,8 @@ var $window = $(window), |
|
|
var mySwiper;
|
|
|
*/
|
|
|
|
|
|
var avatarKey, bannerLen, res, avatarSwiper, avatarSwiperClone, getIndexHtml, $avatarClone, $starArticle;
|
|
|
var avatarKey, bannerLen, res, avatarSwiper, avatarSwiperClone, getIndexHtml,
|
|
|
$avatarClone, $starArticle, $avatarWrap, starIScroll;
|
|
|
|
|
|
var swiperNum = ($('.swiper-num2').width() - $('.swiper-num1').width()) +
|
|
|
($('.swiper-num3').width() - $('.swiper-num1').width()) / 2;
|
...
|
...
|
@@ -91,66 +93,6 @@ function bindAvatar(dom) { |
|
|
}
|
|
|
|
|
|
function setIndexAction() {
|
|
|
var starIScroll;
|
|
|
|
|
|
var $loadingTip = $('.loading-tip'),
|
|
|
$avatarWrap = $('.avatar-wrap:not(.avatar-clone)');
|
|
|
|
|
|
// 下拉刷新,上拉加载
|
|
|
starIScroll = new PullRefresh('.star-wrap', {
|
|
|
height: scrollH,
|
|
|
pullDown: function() {
|
|
|
if (!stopLoading) {
|
|
|
stopLoading = true;
|
|
|
getIndexHtml();
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
starIScroll.iScroll.on('scrollStart', function() {
|
|
|
// 下拉
|
|
|
if (this.directionY === -1) {
|
|
|
$loadingTip.slideDown();
|
|
|
}
|
|
|
});
|
|
|
|
|
|
starIScroll.iScroll.on('scroll', function() {
|
|
|
if ($avatarWrap.offset().top <= headTabH) {
|
|
|
$avatarClone.show();
|
|
|
|
|
|
if (!avatarSwiperClone) {
|
|
|
avatarSwiperClone = new Swiper('.avatar-0', {
|
|
|
loop: true,
|
|
|
initialSlide: $('.avatar-1').find('.swiper-slide-active').index() % bannerLen,
|
|
|
centeredSlides: true,
|
|
|
slidesPerView: 'auto',
|
|
|
loopedSlides: bannerLen,
|
|
|
spaceBetween: 10,
|
|
|
slidesOffsetBefore: -swiperNum,
|
|
|
watchSlidesProgress: true,
|
|
|
watchSlidesVisibility: true,
|
|
|
onInit: function() {
|
|
|
$('.avatar-0 li').on('click', function() {
|
|
|
res = bindAvatar($(this));
|
|
|
return res;
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
|
|
|
avatarSwiperClone.params.control = avatarSwiper;
|
|
|
avatarSwiper.params.control = avatarSwiperClone;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if ($avatarWrap.offset().top > $('.avatar-1')[0].scrollHeight) {
|
|
|
$avatarClone.hide();
|
|
|
}
|
|
|
});
|
|
|
|
|
|
starIScroll.iScroll.on('scrollEnd', function() {
|
|
|
$loadingTip.slideUp();
|
|
|
});
|
|
|
|
|
|
$('.avatar').each(function(key, item) {
|
|
|
$(item).addClass('avatar-' + key);
|
|
|
});
|
...
|
...
|
@@ -229,13 +171,14 @@ function setIndexAction() { |
|
|
|
|
|
function initAction() {
|
|
|
$starArticle = $('.star-article');
|
|
|
$avatarWrap = $('.avatar-wrap');
|
|
|
bannerLen = $('.avatar-wrap').find('.swiper-slide').length;
|
|
|
|
|
|
if ($avatarClone) {
|
|
|
$avatarClone.remove();
|
|
|
}
|
|
|
|
|
|
$starMain.before($('.avatar-swiper').clone().addClass('avatar-clone').hide());
|
|
|
$loadingTip.before($('.avatar-swiper').clone().addClass('avatar-clone').hide());
|
|
|
|
|
|
$avatarClone = $('.avatar-clone');
|
|
|
|
...
|
...
|
@@ -265,7 +208,7 @@ getIndexHtml = function() { |
|
|
avatarSwiperClone = '';
|
|
|
}
|
|
|
|
|
|
$starMain.html(data);
|
|
|
$mainContent.html(data);
|
|
|
|
|
|
initAction();
|
|
|
}
|
...
|
...
|
@@ -280,6 +223,61 @@ getIndexHtml = function() { |
|
|
|
|
|
initAction();
|
|
|
|
|
|
// 下拉刷新,上拉加载
|
|
|
starIScroll = new PullRefresh('.star-main', {
|
|
|
height: scrollH,
|
|
|
pullDown: function() {
|
|
|
if (!stopLoading) {
|
|
|
stopLoading = true;
|
|
|
getIndexHtml();
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
starIScroll.iScroll.on('scrollStart', function() {
|
|
|
// 下拉
|
|
|
if (this.directionY === -1) {
|
|
|
$loadingTip.slideDown();
|
|
|
}
|
|
|
});
|
|
|
|
|
|
starIScroll.iScroll.on('scroll', function() {
|
|
|
if ($avatarWrap.offset().top <= headTabH) {
|
|
|
$avatarClone.show();
|
|
|
|
|
|
if (!avatarSwiperClone) {
|
|
|
avatarSwiperClone = new Swiper('.avatar-0', {
|
|
|
loop: true,
|
|
|
initialSlide: $('.avatar-1').find('.swiper-slide-active').index() % bannerLen,
|
|
|
centeredSlides: true,
|
|
|
slidesPerView: 'auto',
|
|
|
loopedSlides: bannerLen,
|
|
|
spaceBetween: 10,
|
|
|
slidesOffsetBefore: -swiperNum,
|
|
|
watchSlidesProgress: true,
|
|
|
watchSlidesVisibility: true,
|
|
|
onInit: function() {
|
|
|
$('.avatar-0 li').on('click', function() {
|
|
|
res = bindAvatar($(this));
|
|
|
return res;
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
|
|
|
avatarSwiperClone.params.control = avatarSwiper;
|
|
|
avatarSwiper.params.control = avatarSwiperClone;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if ($avatarWrap.offset().top > $('.avatar-1')[0].scrollHeight) {
|
|
|
$avatarClone.hide();
|
|
|
}
|
|
|
});
|
|
|
|
|
|
starIScroll.iScroll.on('scrollEnd', function() {
|
|
|
$loadingTip.slideUp();
|
|
|
});
|
|
|
|
|
|
window.setCookie('guangStarUid', window.queryString.uid);
|
|
|
|
|
|
// 明星动态文章图片相关操作
|
...
|
...
|
|