-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add scroll helper, auto scroll for thread
- Loading branch information
1 parent
77c9f46
commit 207a93b
Showing
4 changed files
with
27 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
export const scrollToBottom = ({ immediately = false }) => { | ||
window.scrollTo({ | ||
top: document.documentElement.scrollHeight, | ||
behavior: immediately ? "instant" : "smooth", | ||
}); | ||
}; | ||
|
||
export const autoScrollToBottom = () => { | ||
if (autoScroll) { | ||
scrollToBottom({ immediately: true }); | ||
} | ||
}; | ||
|
||
export const onScroll = () => { | ||
const scrollPosition = window.pageYOffset + window.innerHeight; | ||
autoScroll = scrollPosition >= document.documentElement.scrollHeight - 40; | ||
}; | ||
|
||
export let autoScroll = false; |