回答
注意要點:
這裏的訣竅,不使用默認的擺動寬鬆在動畫功能上使動畫無縫。
此外,您不能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