updated protocols
This commit is contained in:
parent
7283e3f6f9
commit
531a32a5a5
37 changed files with 682 additions and 650 deletions
|
|
@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue