Authored by xuqi

加载更多功能和样式

@@ -17,7 +17,14 @@ exports.init = function() { @@ -17,7 +17,14 @@ exports.init = function() {
17 $(function() { 17 $(function() {
18 var $intro = $('#intro'), 18 var $intro = $('#intro'),
19 $infoContent = $('#info-content'), 19 $infoContent = $('#info-content'),
  20 + $loadMore = $('#load-more-info'),
  21 + $loadStatus = $loadMore.children('.status'),
  22 + $loading = $loadStatus.filter('.loading'),
  23 + $noMore = $loadStatus.filter('.no-more'),
  24 + loadMoreH = $loadMore.height(),
  25 + winH = $(window).height(),
20 dataEnd = false, 26 dataEnd = false,
  27 + canScroll = true,
21 tpl; 28 tpl;
22 29
23 //获取相关资讯模板 30 //获取相关资讯模板
@@ -58,12 +65,23 @@ exports.init = function() { @@ -58,12 +65,23 @@ exports.init = function() {
58 //下拉加载更多 65 //下拉加载更多
59 $(window).scroll(function() { 66 $(window).scroll(function() {
60 var count; 67 var count;
61 - if ($(window).scrollTop() + $(window).height() >= $(document).height()) { 68 +
  69 + if (!canScroll) {
  70 + return;
  71 + }
  72 +
  73 + if ($(window).scrollTop() + winH >= $(document).height() - loadMoreH) {
62 //loadData 74 //loadData
63 if (dataEnd) { 75 if (dataEnd) {
64 //下次下拉时不显示加载图片以及不加载数据 76 //下次下拉时不显示加载图片以及不加载数据
  77 + $loading.addClass('hide');
  78 + $noMore.removeClass('hide');
65 } else { 79 } else {
  80 + $loading.removeClass('hide');
  81 + $noMore.addClass('hide')
  82 +
66 count = $infoContent.children('.info-block').length; 83 count = $infoContent.children('.info-block').length;
  84 + canScroll = false;
67 $.ajax({ 85 $.ajax({
68 type: 'GET', 86 type: 'GET',
69 url: '/ps/loadInfo', 87 url: '/ps/loadInfo',
@@ -90,6 +108,7 @@ exports.init = function() { @@ -90,6 +108,7 @@ exports.init = function() {
90 container: $infoContent 108 container: $infoContent
91 }); 109 });
92 } 110 }
  111 + canScroll = true;
93 } 112 }
94 }); 113 });
95 } 114 }
1 -@import "compass", "compass/reset"; 1 +@import "compass", "compass/reset", "compass/css3";
2 $pxConvertRem : 40; 2 $pxConvertRem : 40;
3 3
4 body { 4 body {
@@ -11,7 +11,7 @@ ol, ul { @@ -11,7 +11,7 @@ ol, ul {
11 } 11 }
12 12
13 .hide { 13 .hide {
14 - display: none; 14 + display: none !important;
15 } 15 }
16 16
17 /** 17 /**
@@ -69,7 +69,7 @@ ol, ul { @@ -69,7 +69,7 @@ ol, ul {
69 } 69 }
70 /*以上为common部分 代码合并develop后移除*/ 70 /*以上为common部分 代码合并develop后移除*/
71 71
72 -@import "common/time-view-like-share", "common/good-info"; 72 +@import "common/time-view-like-share", "common/good-info", "common/loader";
73 73
74 .ps-container { 74 .ps-container {
75 .ps-block { 75 .ps-block {
@@ -240,5 +240,32 @@ ol, ul { @@ -240,5 +240,32 @@ ol, ul {
240 } 240 }
241 } 241 }
242 } 242 }
  243 +}
243 244
  245 +.load-more-info {
  246 + width: 100%;
  247 + height: 70rem / $pxConvertRem;
  248 + line-height: 70rem / $pxConvertRem;
  249 + text-align: center;
  250 + font-size: 14px;
  251 + overflow: hidden;
  252 +
  253 + .loading {
  254 + display: inline-block;
  255 + vertical-align: top;
  256 +
  257 + .loader-inner {
  258 + display: inline-block;
  259 + height: 40rem / $pxConvertRem;
  260 + width: 40rem / $pxConvertRem;
  261 + margin-top: 12rem / $pxConvertRem;
  262 +
  263 + > div {
  264 + height: 30rem / $pxConvertRem;
  265 + width: 30rem / $pxConvertRem;
  266 + border: 2px solid #f00;
  267 + border-bottom-color: transparent;
  268 + }
  269 + }
  270 + }
244 } 271 }
@@ -48,5 +48,14 @@ @@ -48,5 +48,14 @@
48 {{/ info}} 48 {{/ info}}
49 </div> 49 </div>
50 </div> 50 </div>
  51 + <div id="load-more-info" class="load-more-info">
  52 + <div class="loading status">
  53 + <div class="loader-inner ball-clip-rotate">
  54 + <div></div>
  55 + </div>
  56 + 正在加载...
  57 + </div>
  58 + <span class="no-more status hide">没有更多的资讯</span>
  59 + </div>
51 {{/ data}} 60 {{/ data}}
52 </div> 61 </div>