Authored by 王水玲

星潮优化

@@ -67,7 +67,7 @@ function scrollHandler() { @@ -67,7 +67,7 @@ function scrollHandler() {
67 } 67 }
68 68
69 $(window).scroll(function() { 69 $(window).scroll(function() {
70 - scrollHandler(); 70 + window.requestAnimationFrame(scrollHandler);
71 }); 71 });
72 72
73 if ($('.collocation-list').find('li').length === 0) { 73 if ($('.collocation-list').find('li').length === 0) {
@@ -68,7 +68,7 @@ function scrollHandler() { @@ -68,7 +68,7 @@ function scrollHandler() {
68 } 68 }
69 69
70 $(window).scroll(function() { 70 $(window).scroll(function() {
71 - scrollHandler(); 71 + window.requestAnimationFrame(scrollHandler);
72 }); 72 });
73 73
74 if ($detailList.find('li').length === 0) { 74 if ($detailList.find('li').length === 0) {
@@ -15,7 +15,9 @@ var $ = require('yoho-jquery'), @@ -15,7 +15,9 @@ var $ = require('yoho-jquery'),
15 var $window = $(window), 15 var $window = $(window),
16 stopLoading = false, 16 stopLoading = false,
17 $starMain = $('.star-main'), 17 $starMain = $('.star-main'),
18 - $headTab = $('.head-tab'); 18 + $headTab = $('.head-tab'),
  19 + headTabH = $headTab.height(),
  20 + scrollH = $(window).height() - headTabH;
19 21
20 /* 22 /*
21 $swiperView = $('.swiper-view'), 23 $swiperView = $('.swiper-view'),
@@ -27,7 +29,7 @@ var $window = $(window), @@ -27,7 +29,7 @@ var $window = $(window),
27 var mySwiper; 29 var mySwiper;
28 */ 30 */
29 31
30 -var avatarKey, bannerLen, res, avatarSwiper, avatarSwiperClone, getIndexHtml, $avatarClone, $avatar, $starArticle; 32 +var avatarKey, bannerLen, res, avatarSwiper, avatarSwiperClone, getIndexHtml, $avatarClone, $starArticle;
31 33
32 var swiperNum = ($('.swiper-num2').width() - $('.swiper-num1').width()) + 34 var swiperNum = ($('.swiper-num2').width() - $('.swiper-num1').width()) +
33 ($('.swiper-num3').width() - $('.swiper-num1').width()) / 2; 35 ($('.swiper-num3').width() - $('.swiper-num1').width()) / 2;
@@ -74,11 +76,11 @@ function bindAvatar(dom) { @@ -74,11 +76,11 @@ function bindAvatar(dom) {
74 76
75 if (!dom.hasClass('swiper-slide-active')) { 77 if (!dom.hasClass('swiper-slide-active')) {
76 if (avatarKey >= (2 * bannerLen + 1)) { 78 if (avatarKey >= (2 * bannerLen + 1)) {
77 - avatarSwiperClone && avatarSwiperClone.slideTo(bannerLen + 1, 200);  
78 - avatarSwiper.slideTo(bannerLen + 1, 200); 79 + avatarSwiperClone && avatarSwiperClone.slideTo(bannerLen + 1, 0);
  80 + avatarSwiper.slideTo(bannerLen + 1, 0);
79 } else if (avatarKey <= (bannerLen - 1)) { 81 } else if (avatarKey <= (bannerLen - 1)) {
80 - avatarSwiperClone && avatarSwiperClone.slideTo(2 * bannerLen - 1, 200);  
81 - avatarSwiper.slideTo(2 * bannerLen - (bannerLen - avatarKey), 200); 82 + avatarSwiperClone && avatarSwiperClone.slideTo(2 * bannerLen - 1, 0);
  83 + avatarSwiper.slideTo(2 * bannerLen - (bannerLen - avatarKey), 0);
82 } else { 84 } else {
83 avatarSwiperClone && avatarSwiperClone.slideTo(avatarKey, 200); 85 avatarSwiperClone && avatarSwiperClone.slideTo(avatarKey, 200);
84 avatarSwiper.slideTo(avatarKey, 200); 86 avatarSwiper.slideTo(avatarKey, 200);
@@ -96,7 +98,7 @@ function setIndexAction() { @@ -96,7 +98,7 @@ function setIndexAction() {
96 98
97 // 下拉刷新,上拉加载 99 // 下拉刷新,上拉加载
98 starIScroll = new PullRefresh('.star-wrap', { 100 starIScroll = new PullRefresh('.star-wrap', {
99 - height: $(window).height() - $headTab.height(), 101 + height: scrollH,
100 pullDown: function() { 102 pullDown: function() {
101 if (!stopLoading) { 103 if (!stopLoading) {
102 stopLoading = true; 104 stopLoading = true;
@@ -118,7 +120,7 @@ function setIndexAction() { @@ -118,7 +120,7 @@ function setIndexAction() {
118 }); 120 });
119 121
120 starIScroll.iScroll.on('scroll', function() { 122 starIScroll.iScroll.on('scroll', function() {
121 - if ($avatarWrap.offset().top <= $headTab.height()) { 123 + if ($avatarWrap.offset().top <= headTabH) {
122 $avatarClone.show(); 124 $avatarClone.show();
123 125
124 if (!avatarSwiperClone) { 126 if (!avatarSwiperClone) {
@@ -231,9 +233,8 @@ function setIndexAction() { @@ -231,9 +233,8 @@ function setIndexAction() {
231 } 233 }
232 234
233 function initAction() { 235 function initAction() {
234 - $avatar = $('.avatar');  
235 $starArticle = $('.star-article'); 236 $starArticle = $('.star-article');
236 - bannerLen = $avatar.find('.swiper-slide').length; 237 + bannerLen = $('.avatar-wrap').find('.swiper-slide').length;
237 238
238 if ($avatarClone) { 239 if ($avatarClone) {
239 $avatarClone.remove(); 240 $avatarClone.remove();
@@ -250,9 +251,7 @@ function initAction() { @@ -250,9 +251,7 @@ function initAction() {
250 251
251 lazyLoad($('img.lazy')); 252 lazyLoad($('img.lazy'));
252 253
253 - setTimeout(function() {  
254 setIndexAction(); 254 setIndexAction();
255 - }, 100);  
256 } 255 }
257 256
258 257