fix: firefox fix bottom bar

This commit is contained in:
Jean-Baptiste Pasquier 2020-10-15 16:16:27 +02:00
parent b5a267d84b
commit 0bd9df44a9
1 changed files with 41 additions and 9 deletions

View File

@ -1,23 +1,55 @@
document.addEventListener("DOMContentLoaded", () => {
window.scrollTo(0, 1);
let scrollTop = 1;
let fromTop = () => {
return window.pageYOffset || document.compatMode === "CSS1Compat" && document.documentElement.scrollTop || document.body.scrollTop || 0;
const resizeChat = () => {
let chatBox = Array.from(document.querySelectorAll("solid-xmpp-chat"))
.map((el) => el.shadowRoot ? el.shadowRoot.getElementById("conversejs") : false)
.filter((el) => el)
.pop();
if (chatBox) {
let chatTextArea = chatBox.querySelector(".message-form-container");
let ischatTextArea = setInterval(() => {
chatTextArea = chatBox.querySelector(".message-form-container");
if (chatTextArea) {
clearInterval(ischatTextArea);
if (
chatBox.getBoundingClientRect().height -
chatTextArea.getBoundingClientRect().height !=
chatTextArea.offsetTop
) {
let viewportChat = Array.from(
document.querySelectorAll("#viewport .chat-view")
);
viewportChat.forEach(
(c) => (c.style.height = "calc(100vh - 106px - 57px - 4px)")
);
}
}
}, 15);
}
};
resizeChat();
let isbody = setInterval(() => {
if (document.body) {
clearInterval(isbody);
scrollTop = fromTop();
window.scrollTo(0, scrollTop === 1 ? 0 : 1);
resizeChat();
}
}, 15);
window.addEventListener("load", () => {
setTimeout(() => {
if (fromTop() < 20) {
window.scrollTo(0, scrollTop === 1 ? 0 : 1);
}
resizeChat();
}, 0);
});
window.addEventListener("resize", () => {
setTimeout(() => {
resizeChat();
}, 0);
});
document.addEventListener("navigate", () => {
setTimeout(() => {
resizeChat();
}, 0);
});
});