updated protocols

This commit is contained in:
Andrew Gundersen 2021-07-11 11:54:39 -05:00
commit 531a32a5a5
37 changed files with 682 additions and 650 deletions

View file

@ -1,33 +1,25 @@
export default function useScroll(elementId: string) {
// Update isScrolledToBottom
const isScrolledToBottom = () => {
const el = document.getElementById(elementId);
const el = document.getElementById(elementId);
const isBottom = () => {
if (el) {
return el.scrollHeight - el.clientHeight <= el.scrollTop + 30;
return el.scrollHeight - el.clientHeight <= el.scrollTop + 1;
}
}
// Adjust scroll after we add content to the messenger.
const adjustScroll = () => {
const el = document.getElementById(elementId);
if (el) {
el.scrollTo({
top: el.scrollHeight - el.clientHeight,
behavior: 'smooth'
});
}
}
return {
isScrolledToBottom,
adjustScroll,
};
if (el)
el.addEventListener('adjust-scroll', adjustScroll);
window.addEventListener('resize', adjustScroll);
}
}