fix chat scroll, luke ist dafür verantwortlich

This commit is contained in:
Fabian
2021-04-21 20:03:54 +02:00
parent ee2a13fea0
commit 3cbca7ec1e

View File

@@ -23,7 +23,8 @@ function enableChatInput(enable) {
if (enable) { if (enable) {
chat.input = $("#chat").append('<div><input id="chat_msg" type="text" /></div>').children(":last"); chat.input = $("#chat").append('<div><input id="chat_msg" type="text" /></div>').children(":last");
chat.input.children("input").focus(); chat.input.children("input").focus();
} else { }
else {
chat.input.fadeOut('fast', function () { chat.input.fadeOut('fast', function () {
chat.input.remove(); chat.input.remove();
chat.input = null; chat.input = null;
@@ -64,14 +65,12 @@ var chatAPI =
var today = new Date(); var today = new Date();
if (chatElement === "<li></li>") { if (chatElement === "<li></li>") {
var time = today.toLocaleTimeString('de-DE');
chat.container.append("<li>" + "[" + time + "] " + text + "</li>");
if (chat.input == null || elmnt.scrollTop == elmnt.scrollHeight - elmnt.clientHeight) { if (chat.input == null || elmnt.scrollTop == elmnt.scrollHeight - elmnt.clientHeight) {
chat.container.append("<li>" + "[" + today.toLocaleTimeString('de-DE') + "] " + text + "</li>");
elmnt.scrollTop = elmnt.scrollHeight - elmnt.clientHeight; elmnt.scrollTop = elmnt.scrollHeight - elmnt.clientHeight;
} else {
chat.container.append("<li>" + "[" + today.toLocaleTimeString('de-DE') + "] " + text + "</li>");
} }
// if (!chat.enabled) { elmnt.scrollTo(0, elmnt.scrollHeight); }
} else { } else {
chat.container.append(chatElement); chat.container.append(chatElement);
} }