$(function() {
$(window).scroll(function(){
checkY();
});
$('.post').last().after('<div class="newPost" />');
var hrefArray = [],//array global
hrefs = $('.paging a[href*="/t"]').not('.paging a[href*="/t"] > img');
for(var i=0;i<hrefs.length;i++) {
var hreflink = $(hrefs[i]).attr('href');
hrefArray.push(hreflink);
}
hrefArray.pop();
var postedLast = $('.post').last().position().top + $('.post').last().outerHeight();
function checkY(){
if(hrefArray.length > 1) {
if($(window).scrollTop() > postedLast){
var url = hrefArray.shift();
$('.newPost').html('<img class="loadingImg" src="http://i79.servimg.com/u/f79/17/83/35/07/loadin10.gif"/>');
setTimeout(function() {
$('.loadingImg').remove();
$('.newPost').last().load(url+" .post",function() {
//THIS LINE BELOW IS THE PROBLEM
$('.newPost').last().after('<div class="newPost" />');
postedLast = $('.post').last().position().top +
$('.post').last().outerHeight();
});
},3000);
}
}
}
window.onLoad = checkY();
});
위의 코드는 무한 스크롤의 모의 객체입니다. 내 문제는 그 라인을 계속해서 계속 덧붙여 두는 것이다. 한 번 추가하는 방법이 있습니까? 나는 이것을 위해 거의 모든 것을 시도해 왔고, 지금까지 그렇게 노력하지 않았다. 또한이 대신에 방법이 있습니다요소를 여러 번 추가하는 무한 스크롤 문제
$('.post').last().position().top + $('.post').last().outerHeight();
시간에로드하고 싶지 않은 것 같습니다. 엘리먼트가 화면 하단에 오면 기능을 수행합니다. 이 때문에 - if($(window).scrollTop() > postedLast){
다른 방법이 있나요? 따라서 화면 맨 위에있는 대신 화면 맨 아래에서 작동합니까? 확인이 밖으로