아이패드 호환 lazyload 효과

6840 단어 lazyload

  
  
function lazyload(option){
alert(
" wwwwwwwwwwwwwwww " );
var settings = {
defObj:
null ,
defHeight:
0
};
settings
= $.extend(settings,option || {});
var defHeight = settings.defHeight,defObj = ( typeof settings.defObj == " object " ) ? settings.defObj.find( " img " ):$(settings.defObj).find( " img " );
var pageTop = function (){

var ua = navigator.userAgent.toLowerCase();
if (ua.match( / iPad / i) == " ipad " ) {
return document.documentElement.clientHeight + window.pageYOffset - settings.defHeight;
}
else {
return document.documentElement.clientHeight + Math.max(document.documentElement.scrollTop, document.body.scrollTop) - settings.defHeight;
}



};
var imgLoad = function (){
defObj.each(
function (){
if ($( this ).offset().top <= pageTop()){
var src2 = $( this ).attr( " src2 " );
if (src2){
$(
this ).attr( " src " ,src2).removeAttr( " src2 " );
}
}
});
};
imgLoad();
$(window).bind(
" scroll " , function (){
imgLoad();
});
}
lazyload({
defObj:
" #special1 "
});
lazyload({
defObj:
" #special2 "
});

좋은 웹페이지 즐겨찾기