fix not starting out scrolled down
This commit is contained in:
parent
745491b7fe
commit
84e715d480
1 changed files with 5 additions and 2 deletions
7
main.js
7
main.js
|
@ -48,7 +48,7 @@ document.querySelector('.form__input-submit').addEventListener('click', function
|
||||||
function getMessages() {
|
function getMessages() {
|
||||||
const timestamp = (document.querySelector('.chat').lastElementChild) ? document.querySelector('.chat').lastElementChild.getAttribute('data-timestamp') : 0
|
const timestamp = (document.querySelector('.chat').lastElementChild) ? document.querySelector('.chat').lastElementChild.getAttribute('data-timestamp') : 0
|
||||||
|
|
||||||
fetch('api.php?action=getMessages×tamp=' + timestamp)
|
return fetch('api.php?action=getMessages×tamp=' + timestamp)
|
||||||
.then(function (data) {
|
.then(function (data) {
|
||||||
return data.json()
|
return data.json()
|
||||||
})
|
})
|
||||||
|
@ -106,7 +106,10 @@ function createMessageNode(name, text, timestamp, datetime) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
getMessages()
|
getMessages().then(() => {
|
||||||
|
scrollWindowDown()
|
||||||
|
})
|
||||||
|
|
||||||
setInterval(function () {
|
setInterval(function () {
|
||||||
getMessages()
|
getMessages()
|
||||||
}, 2000)
|
}, 2000)
|
||||||
|
|
Loading…
Reference in a new issue