|
@@ -14,10 +14,11 @@ var $ = require('yoho-jquery'), |
|
@@ -14,10 +14,11 @@ var $ = require('yoho-jquery'), |
14
|
|
14
|
|
15
|
var $window = $(window),
|
15
|
var $window = $(window),
|
16
|
stopLoading = false,
|
16
|
stopLoading = false,
|
17
|
- $starMain = $('.star-main'),
|
17
|
+ $mainContent = $('.main-content'),
|
18
|
$headTab = $('.head-tab'),
|
18
|
$headTab = $('.head-tab'),
|
19
|
headTabH = $headTab.height(),
|
19
|
headTabH = $headTab.height(),
|
20
|
- scrollH = $(window).height() - headTabH;
|
20
|
+ scrollH = $(window).height() - headTabH,
|
|
|
21
|
+ $loadingTip = $('.loading-tip');
|
21
|
|
22
|
|
22
|
/*
|
23
|
/*
|
23
|
$swiperView = $('.swiper-view'),
|
24
|
$swiperView = $('.swiper-view'),
|
|
@@ -29,7 +30,8 @@ var $window = $(window), |
|
@@ -29,7 +30,8 @@ var $window = $(window), |
29
|
var mySwiper;
|
30
|
var mySwiper;
|
30
|
*/
|
31
|
*/
|
31
|
|
32
|
|
32
|
-var avatarKey, bannerLen, res, avatarSwiper, avatarSwiperClone, getIndexHtml, $avatarClone, $starArticle;
|
33
|
+var avatarKey, bannerLen, res, avatarSwiper, avatarSwiperClone, getIndexHtml,
|
|
|
34
|
+ $avatarClone, $starArticle, $avatarWrap, starIScroll;
|
33
|
|
35
|
|
34
|
var swiperNum = ($('.swiper-num2').width() - $('.swiper-num1').width()) +
|
36
|
var swiperNum = ($('.swiper-num2').width() - $('.swiper-num1').width()) +
|
35
|
($('.swiper-num3').width() - $('.swiper-num1').width()) / 2;
|
37
|
($('.swiper-num3').width() - $('.swiper-num1').width()) / 2;
|
|
@@ -91,66 +93,6 @@ function bindAvatar(dom) { |
|
@@ -91,66 +93,6 @@ function bindAvatar(dom) { |
91
|
}
|
93
|
}
|
92
|
|
94
|
|
93
|
function setIndexAction() {
|
95
|
function setIndexAction() {
|
94
|
- var starIScroll;
|
|
|
95
|
-
|
|
|
96
|
- var $loadingTip = $('.loading-tip'),
|
|
|
97
|
- $avatarWrap = $('.avatar-wrap:not(.avatar-clone)');
|
|
|
98
|
-
|
|
|
99
|
- // 下拉刷新,上拉加载
|
|
|
100
|
- starIScroll = new PullRefresh('.star-wrap', {
|
|
|
101
|
- height: scrollH,
|
|
|
102
|
- pullDown: function() {
|
|
|
103
|
- if (!stopLoading) {
|
|
|
104
|
- stopLoading = true;
|
|
|
105
|
- getIndexHtml();
|
|
|
106
|
- }
|
|
|
107
|
- }
|
|
|
108
|
- });
|
|
|
109
|
-
|
|
|
110
|
- starIScroll.iScroll.on('scrollStart', function() {
|
|
|
111
|
- // 下拉
|
|
|
112
|
- if (this.directionY === -1) {
|
|
|
113
|
- $loadingTip.slideDown();
|
|
|
114
|
- }
|
|
|
115
|
- });
|
|
|
116
|
-
|
|
|
117
|
- starIScroll.iScroll.on('scroll', function() {
|
|
|
118
|
- if ($avatarWrap.offset().top <= headTabH) {
|
|
|
119
|
- $avatarClone.show();
|
|
|
120
|
-
|
|
|
121
|
- if (!avatarSwiperClone) {
|
|
|
122
|
- avatarSwiperClone = new Swiper('.avatar-0', {
|
|
|
123
|
- loop: true,
|
|
|
124
|
- initialSlide: $('.avatar-1').find('.swiper-slide-active').index() % bannerLen,
|
|
|
125
|
- centeredSlides: true,
|
|
|
126
|
- slidesPerView: 'auto',
|
|
|
127
|
- loopedSlides: bannerLen,
|
|
|
128
|
- spaceBetween: 10,
|
|
|
129
|
- slidesOffsetBefore: -swiperNum,
|
|
|
130
|
- watchSlidesProgress: true,
|
|
|
131
|
- watchSlidesVisibility: true,
|
|
|
132
|
- onInit: function() {
|
|
|
133
|
- $('.avatar-0 li').on('click', function() {
|
|
|
134
|
- res = bindAvatar($(this));
|
|
|
135
|
- return res;
|
|
|
136
|
- });
|
|
|
137
|
- }
|
|
|
138
|
- });
|
|
|
139
|
-
|
|
|
140
|
- avatarSwiperClone.params.control = avatarSwiper;
|
|
|
141
|
- avatarSwiper.params.control = avatarSwiperClone;
|
|
|
142
|
- }
|
|
|
143
|
- }
|
|
|
144
|
-
|
|
|
145
|
- if ($avatarWrap.offset().top > $('.avatar-1')[0].scrollHeight) {
|
|
|
146
|
- $avatarClone.hide();
|
|
|
147
|
- }
|
|
|
148
|
- });
|
|
|
149
|
-
|
|
|
150
|
- starIScroll.iScroll.on('scrollEnd', function() {
|
|
|
151
|
- $loadingTip.slideUp();
|
|
|
152
|
- });
|
|
|
153
|
-
|
|
|
154
|
$('.avatar').each(function(key, item) {
|
96
|
$('.avatar').each(function(key, item) {
|
155
|
$(item).addClass('avatar-' + key);
|
97
|
$(item).addClass('avatar-' + key);
|
156
|
});
|
98
|
});
|
|
@@ -229,13 +171,14 @@ function setIndexAction() { |
|
@@ -229,13 +171,14 @@ function setIndexAction() { |
229
|
|
171
|
|
230
|
function initAction() {
|
172
|
function initAction() {
|
231
|
$starArticle = $('.star-article');
|
173
|
$starArticle = $('.star-article');
|
|
|
174
|
+ $avatarWrap = $('.avatar-wrap');
|
232
|
bannerLen = $('.avatar-wrap').find('.swiper-slide').length;
|
175
|
bannerLen = $('.avatar-wrap').find('.swiper-slide').length;
|
233
|
|
176
|
|
234
|
if ($avatarClone) {
|
177
|
if ($avatarClone) {
|
235
|
$avatarClone.remove();
|
178
|
$avatarClone.remove();
|
236
|
}
|
179
|
}
|
237
|
|
180
|
|
238
|
- $starMain.before($('.avatar-swiper').clone().addClass('avatar-clone').hide());
|
181
|
+ $loadingTip.before($('.avatar-swiper').clone().addClass('avatar-clone').hide());
|
239
|
|
182
|
|
240
|
$avatarClone = $('.avatar-clone');
|
183
|
$avatarClone = $('.avatar-clone');
|
241
|
|
184
|
|
|
@@ -265,7 +208,7 @@ getIndexHtml = function() { |
|
@@ -265,7 +208,7 @@ getIndexHtml = function() { |
265
|
avatarSwiperClone = '';
|
208
|
avatarSwiperClone = '';
|
266
|
}
|
209
|
}
|
267
|
|
210
|
|
268
|
- $starMain.html(data);
|
211
|
+ $mainContent.html(data);
|
269
|
|
212
|
|
270
|
initAction();
|
213
|
initAction();
|
271
|
}
|
214
|
}
|
|
@@ -280,6 +223,61 @@ getIndexHtml = function() { |
|
@@ -280,6 +223,61 @@ getIndexHtml = function() { |
280
|
|
223
|
|
281
|
initAction();
|
224
|
initAction();
|
282
|
|
225
|
|
|
|
226
|
+// 下拉刷新,上拉加载
|
|
|
227
|
+starIScroll = new PullRefresh('.star-main', {
|
|
|
228
|
+ height: scrollH,
|
|
|
229
|
+ pullDown: function() {
|
|
|
230
|
+ if (!stopLoading) {
|
|
|
231
|
+ stopLoading = true;
|
|
|
232
|
+ getIndexHtml();
|
|
|
233
|
+ }
|
|
|
234
|
+ }
|
|
|
235
|
+});
|
|
|
236
|
+
|
|
|
237
|
+starIScroll.iScroll.on('scrollStart', function() {
|
|
|
238
|
+ // 下拉
|
|
|
239
|
+ if (this.directionY === -1) {
|
|
|
240
|
+ $loadingTip.slideDown();
|
|
|
241
|
+ }
|
|
|
242
|
+});
|
|
|
243
|
+
|
|
|
244
|
+starIScroll.iScroll.on('scroll', function() {
|
|
|
245
|
+ if ($avatarWrap.offset().top <= headTabH) {
|
|
|
246
|
+ $avatarClone.show();
|
|
|
247
|
+
|
|
|
248
|
+ if (!avatarSwiperClone) {
|
|
|
249
|
+ avatarSwiperClone = new Swiper('.avatar-0', {
|
|
|
250
|
+ loop: true,
|
|
|
251
|
+ initialSlide: $('.avatar-1').find('.swiper-slide-active').index() % bannerLen,
|
|
|
252
|
+ centeredSlides: true,
|
|
|
253
|
+ slidesPerView: 'auto',
|
|
|
254
|
+ loopedSlides: bannerLen,
|
|
|
255
|
+ spaceBetween: 10,
|
|
|
256
|
+ slidesOffsetBefore: -swiperNum,
|
|
|
257
|
+ watchSlidesProgress: true,
|
|
|
258
|
+ watchSlidesVisibility: true,
|
|
|
259
|
+ onInit: function() {
|
|
|
260
|
+ $('.avatar-0 li').on('click', function() {
|
|
|
261
|
+ res = bindAvatar($(this));
|
|
|
262
|
+ return res;
|
|
|
263
|
+ });
|
|
|
264
|
+ }
|
|
|
265
|
+ });
|
|
|
266
|
+
|
|
|
267
|
+ avatarSwiperClone.params.control = avatarSwiper;
|
|
|
268
|
+ avatarSwiper.params.control = avatarSwiperClone;
|
|
|
269
|
+ }
|
|
|
270
|
+ }
|
|
|
271
|
+
|
|
|
272
|
+ if ($avatarWrap.offset().top > $('.avatar-1')[0].scrollHeight) {
|
|
|
273
|
+ $avatarClone.hide();
|
|
|
274
|
+ }
|
|
|
275
|
+});
|
|
|
276
|
+
|
|
|
277
|
+starIScroll.iScroll.on('scrollEnd', function() {
|
|
|
278
|
+ $loadingTip.slideUp();
|
|
|
279
|
+});
|
|
|
280
|
+
|
283
|
window.setCookie('guangStarUid', window.queryString.uid);
|
281
|
window.setCookie('guangStarUid', window.queryString.uid);
|
284
|
|
282
|
|
285
|
// 明星动态文章图片相关操作
|
283
|
// 明星动态文章图片相关操作
|