forked from lix-project/hydra
plain-reload: Scroll down at document load.
When visiting the tail-reload page, for a short amount of time the "unscrolled" version is shown. To circumvent that, let's scroll down immediately at the first possibility to fill the gap between the loading of the document and the first AJAX request coming in. Signed-off-by: aszlig <aszlig@redmoonstudios.org>
This commit is contained in:
parent
c251598241
commit
7a48ad375a
|
@ -9,18 +9,23 @@
|
||||||
|
|
||||||
[% IF reload %]
|
[% IF reload %]
|
||||||
<script>
|
<script>
|
||||||
|
function scrollDown() {
|
||||||
|
$("#contents").scrollTop($("#contents").get(0).scrollHeight);
|
||||||
|
}
|
||||||
|
|
||||||
function injectTail() {
|
function injectTail() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "[% url %]",
|
url: "[% url %]",
|
||||||
dataType: "text",
|
dataType: "text",
|
||||||
success: function (tail) {
|
success: function (tail) {
|
||||||
$("#contents").text(tail);
|
$("#contents").text(tail);
|
||||||
$("#contents").scrollTop($("#contents").get(0).scrollHeight);
|
scrollDown();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
scrollDown();
|
||||||
injectTail();
|
injectTail();
|
||||||
setInterval(injectTail, 5000);
|
setInterval(injectTail, 5000);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue