fix not starting out scrolled down

This commit is contained in:
Tomáš Mládek 2018-10-18 12:51:12 +02:00
parent 745491b7fe
commit 84e715d480

View file

@ -48,7 +48,7 @@ document.querySelector('.form__input-submit').addEventListener('click', function
function getMessages() {
const timestamp = (document.querySelector('.chat').lastElementChild) ? document.querySelector('.chat').lastElementChild.getAttribute('data-timestamp') : 0
fetch('api.php?action=getMessages&timestamp=' + timestamp)
return fetch('api.php?action=getMessages&timestamp=' + timestamp)
.then(function (data) {
return data.json()
})
@ -106,7 +106,10 @@ function createMessageNode(name, text, timestamp, datetime) {
return true
}
getMessages()
getMessages().then(() => {
scrollWindowDown()
})
setInterval(function () {
getMessages()
}, 2000)