Authored by xuqi

优化tag页lazyload

... ... @@ -63,6 +63,22 @@ exports.init = function() {
Mustache.parse(tpl);
});
//img-lazyload
function lazyLoad(imgs) {
var $imgs;
if (typeof imgs === 'undefined') {
$imgs = $('img.lazy');
} else {
$imgs = imgs;
}
$imgs.lazyload({
effect : 'fadeIn',
effect_speed: 10,
placeholder: 'data:image/gif;base64,R0lGODlhAQABAJEAAAAAAP///93d3f///yH5BAEAAAMALAAAAAABAAEAAAICVAEAOw=='
});
}
lazyLoad();
//相关文章截取文字
ellipsis.init();
$('.tag-text, .tag-title').each(function() {
... ... @@ -106,7 +122,8 @@ exports.init = function() {
* 加载更多
*/
function loadMore() {
var setting;
var setting,
hasNum = $tagList.find('.tag-content').length;
if (hasAuthor) {
setting = {
... ... @@ -148,13 +165,8 @@ exports.init = function() {
}
if (html !== '') {
$tagList.append(html);
//lazyload 不包含src即未加载的图片
$('img.lazy').lazyload({
effect : 'fadeIn',
container: $tagList,
placeholder: 'data:image/gif;base64,R0lGODlhAQABAJEAAAAAAP///93d3f///yH5BAEAAAMALAAAAAABAAEAAAICVAEAOw=='
});
//lazyload新加载的项
lazyLoad($tagList.find('.tag-content:gt(' + (hasNum - 1) + ') img.lazy'));
//文字截取
$tagList.find('.tag-text, .tag-title').each(function() {
this.mlellipsis(2);
... ...