hubl/src/scripts/firefox-scroll.js

60 lines
1.9 KiB
JavaScript
Raw Normal View History

2020-10-14 21:40:08 +00:00
document.addEventListener("DOMContentLoaded", () => {
2020-10-15 14:16:27 +00:00
const resizeChat = () => {
2020-12-02 09:09:01 +00:00
let isMobile = window.innerWidth < 993;
let isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
let isFirefoxMobile = navigator.platform.toLowerCase().indexOf("mobile") > -1 || navigator.platform.toLowerCase().indexOf("tablet") > -1;
2020-10-15 14:16:27 +00:00
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(
2020-12-02 09:09:01 +00:00
(c) => (c.style.height = isMobile ? (isFirefox && isFirefoxMobile) ? "calc(100vh - 106px - 57px)" : "calc(100vh - 106px)" : "calc(100vh - 64px - 83px)")
2020-10-15 14:16:27 +00:00
);
}
}
}, 15);
}
2020-10-14 21:40:08 +00:00
};
2020-10-15 14:16:27 +00:00
resizeChat();
2020-10-14 21:40:08 +00:00
let isbody = setInterval(() => {
if (document.body) {
clearInterval(isbody);
2020-10-15 14:16:27 +00:00
resizeChat();
2020-10-14 21:40:08 +00:00
}
2020-11-30 17:10:09 +00:00
}, 50);
2020-10-14 21:40:08 +00:00
window.addEventListener("load", () => {
setTimeout(() => {
2020-10-15 14:16:27 +00:00
resizeChat();
}, 0);
});
2020-11-30 17:10:09 +00:00
let windowResizing;
2020-10-15 14:16:27 +00:00
window.addEventListener("resize", () => {
2020-11-30 17:10:09 +00:00
windowResizing = setTimeout(() => {
clearInterval(windowResizing);
2020-10-15 14:16:27 +00:00
resizeChat();
2020-11-30 17:10:09 +00:00
}, 50);
2020-10-15 14:16:27 +00:00
});
document.addEventListener("navigate", () => {
setTimeout(() => {
resizeChat();
2020-10-14 21:40:08 +00:00
}, 0);
});
});