add latest walk lazy load
Showing
5 changed files
with
18 additions
and
14 deletions
@@ -4,5 +4,10 @@ | @@ -4,5 +4,10 @@ | ||
4 | <h2>最近浏览的商品</h2> | 4 | <h2>最近浏览的商品</h2> |
5 | <div id="latest-walk-goods" class="goods clearfix"></div> | 5 | <div id="latest-walk-goods" class="goods clearfix"></div> |
6 | </div> | 6 | </div> |
7 | + <div class="lazy-load-object"> | ||
8 | + <textarea class="latest-walk-datalazyload" style="visibility: hidden;"> | ||
9 | + <script> fetchLatestWalk(); </script> | ||
10 | + </textarea> | ||
11 | + </div> | ||
7 | {{> product/latest-walk-tpl}} | 12 | {{> product/latest-walk-tpl}} |
8 | {{/if}} | 13 | {{/if}} |
@@ -501,7 +501,6 @@ bindEvent.add(function() { | @@ -501,7 +501,6 @@ bindEvent.add(function() { | ||
501 | 501 | ||
502 | // yas | 502 | // yas |
503 | require('../common'); | 503 | require('../common'); |
504 | - | ||
505 | // 最近浏览 | 504 | // 最近浏览 |
506 | require('./detail/latest-walk'); | 505 | require('./detail/latest-walk'); |
507 | 506 | ||
@@ -583,8 +582,7 @@ window.fetchHotArea = fetchHotArea; | @@ -583,8 +582,7 @@ window.fetchHotArea = fetchHotArea; | ||
583 | // 商品详情图片懒加载 | 582 | // 商品详情图片懒加载 |
584 | lazyLoad($('#details-html img')); | 583 | lazyLoad($('#details-html img')); |
585 | 584 | ||
586 | -// 数据懒加载 | ||
587 | -dataLazyLoad.init({cls: 'datalazyload', threshold: -50}); | 585 | + |
588 | 586 | ||
589 | // 咨询和评价 | 587 | // 咨询和评价 |
590 | function fetchComment() { | 588 | function fetchComment() { |
@@ -818,3 +816,6 @@ bindEvent.fire(); | @@ -818,3 +816,6 @@ bindEvent.fire(); | ||
818 | } | 816 | } |
819 | }); | 817 | }); |
820 | }()); | 818 | }()); |
819 | + | ||
820 | +// 数据懒加载 | ||
821 | +dataLazyLoad.init({cls: 'datalazyload', threshold: 0}); |
@@ -7,10 +7,11 @@ | @@ -7,10 +7,11 @@ | ||
7 | var $ = require('yoho-jquery'); | 7 | var $ = require('yoho-jquery'); |
8 | var Handlebars = require('yoho-handlebars'); | 8 | var Handlebars = require('yoho-handlebars'); |
9 | var lazyLoad = require('yoho-jquery-lazyload'); | 9 | var lazyLoad = require('yoho-jquery-lazyload'); |
10 | +var dataLazyLoad = require('../../plugins/lazy-load')(document); | ||
10 | 11 | ||
11 | var $latestWalkCount = $('#latest-walk-count'); | 12 | var $latestWalkCount = $('#latest-walk-count'); |
12 | 13 | ||
13 | -(function() { | 14 | +function fetchLatestWalk() { |
14 | var tpl; | 15 | var tpl; |
15 | 16 | ||
16 | if ($latestWalkCount.length === 0) { | 17 | if ($latestWalkCount.length === 0) { |
@@ -59,4 +60,9 @@ var $latestWalkCount = $('#latest-walk-count'); | @@ -59,4 +60,9 @@ var $latestWalkCount = $('#latest-walk-count'); | ||
59 | } | 60 | } |
60 | } | 61 | } |
61 | }); | 62 | }); |
62 | -}()); | 63 | +} |
64 | + | ||
65 | +window.fetchLatestWalk = fetchLatestWalk; | ||
66 | + | ||
67 | +// 数据懒加载 | ||
68 | +dataLazyLoad.init({cls: 'latest-walk-datalazyload', threshold: 700}); |
-
Please register or login to post a comment