回答
注意要点:
这里的诀窍,不使用默认的摆动宽松在动画功能上使动画无缝。
此外,您不能simply animate to the bottom of the page,但动画的当前scrollTop的下一步。
的jQuery:
$(function() {
// every 1 seconds, check + update
setInterval(appendContent, 800);
setInterval(continueScrolling, 1000);
});
var b = $('body');
// if almost at bottom, append more content
function appendContent() {
if($(window).scrollTop() + $(window).height()*2 > $(document).height()) {
// Load/append your new content here.
// I am doubling the content for demostration purposes.
b.html(b.html() + b.html());
}
}
// continue scrolling linearly
function continueScrolling() {
// get current scroll position
y = $(window).scrollTop();
// stop previous animation, animate to the next 1000 pixels
// to make it scroll faster, increase the constant after the y
$("html, body").stop()
.animate({ scrollTop: y+1000 }, {
duration: 1000, // you won't want to scroll too quickly
easing: 'linear', // cannot use the default 'swing' here
queue: false
});
}
演示:
这是完美的,正是我所需要的。非常感谢! – chrscblls 2013-04-23 06:06:34
欢迎您使用upvote并标记为答案 - 它会为您赢得声誉和徽章! – 2013-04-23 06:07:08
理论上你可以使用javascript来追踪div,因为它滚动的位置是y,并且每N像素使用相同数据/ html/php的jQuery加载到附加的子div中。
我猜我必须尝试一下,看看我能想出什么。
这就是我想出了,似乎在基础层面上工作
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
function keepGoing(counter) {
var objTo = document.getElementById('foreverDiv')
var divtest = document.createElement("moreStuffDiv" + counter);
divtest.setAttribute("id", "moreStuffDiv" + counter);
divtest.innerHTML = "new div " + counter + "<br>";
objTo.appendChild(divtest);
document.getElementById('moreStuffDiv' + counter).scrollIntoView();
counter = counter +1;
}
jQuery(document).ready(function() {
setInterval('keepGoing(1)', 10);
});
</script>
<div id="contentDiv">
<h1>Content</h1>
<div id="foreverDiv">
</div>
</div>
你真的试过了吗? – 2013-04-23 05:19:27
yes @ http://www.dan-elkins.com/forever.html – Silvertiger 2013-04-23 05:23:36
- 1. 创建jQuery无限循环
- 2. $ timeout里面会循环创建无限循环
- 3. 无限循环,页面无法加载
- 4. 如何创建无限循环
- 5. .htaccess重定向创建无限循环
- 6. C++ strcat创建无限循环
- 7. 回调创建无限循环
- 8. 创建HTML内容的JavaScript循环
- 9. 如何创建一个无限循环的循环?
- 10. Do/While循环创建无限循环结合setTimeout
- 11. 动态创建ASP.NET内容页面
- 12. 创建Html.ActionLink到动态内容页面
- 13. 创建页面的动态内容qTip
- 14. 创建多个循环页
- 15. 无限循环
- 16. 无限循环
- 17. 无限循环
- 18. 无限循环
- 19. (?无限)循环
- 20. jQuery脚本在Firefox中创建无限循环(仅限于)
- 21. CUDA内核中的无限循环
- 22. 设置范围内的无限循环
- 23. 无限循环内的多处理
- 24. .animate无限循环
- 25. Prolog无限循环
- 26. Haskell无限循环
- 27. 无限循环inOverrideUrlLoading
- 28. MPLAB无限循环
- 29. Arduino无限循环
- 30. jQuery无限循环
做谷歌搜索。 – 2013-04-23 04:37:30