mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-08-23 17:47:24 +00:00
define magic numbers as constants
This commit is contained in:
parent
f6176f048d
commit
d83856c6cf
1 changed files with 10 additions and 3 deletions
|
@ -28,6 +28,8 @@ type Props = {
|
||||||
|
|
||||||
const VIEW_MODE_CHAT = 'view_chat';
|
const VIEW_MODE_CHAT = 'view_chat';
|
||||||
const VIEW_MODE_SUPER_CHAT = 'view_superchat';
|
const VIEW_MODE_SUPER_CHAT = 'view_superchat';
|
||||||
|
const COMMENT_SCROLL_OFFSET = 100;
|
||||||
|
const COMMENT_SCROLL_TIMEOUT = 25;
|
||||||
|
|
||||||
export default function LivestreamComments(props: Props) {
|
export default function LivestreamComments(props: Props) {
|
||||||
const {
|
const {
|
||||||
|
@ -84,8 +86,8 @@ export default function LivestreamComments(props: Props) {
|
||||||
|
|
||||||
function handleScroll() {
|
function handleScroll() {
|
||||||
if (discussionElement) {
|
if (discussionElement) {
|
||||||
const negativeCommentHeight = commentElement && (-1 * commentElement.offsetHeight);
|
const negativeCommentHeight = commentElement && -1 * commentElement.offsetHeight;
|
||||||
const isAtRecent = negativeCommentHeight && (discussionElement.scrollTop >= negativeCommentHeight);
|
const isAtRecent = negativeCommentHeight && discussionElement.scrollTop >= negativeCommentHeight;
|
||||||
|
|
||||||
setScrollBottom(isAtRecent);
|
setScrollBottom(isAtRecent);
|
||||||
}
|
}
|
||||||
|
@ -98,7 +100,12 @@ export default function LivestreamComments(props: Props) {
|
||||||
// Only update comment scroll if the user hasn't scrolled up to view old comments
|
// Only update comment scroll if the user hasn't scrolled up to view old comments
|
||||||
// If they have, do nothing
|
// If they have, do nothing
|
||||||
if (!performedInitialScroll) {
|
if (!performedInitialScroll) {
|
||||||
setTimeout(() => (discussionElement.scrollTop = discussionElement.scrollHeight - discussionElement.offsetHeight + 100), 20);
|
setTimeout(
|
||||||
|
() =>
|
||||||
|
(discussionElement.scrollTop =
|
||||||
|
discussionElement.scrollHeight - discussionElement.offsetHeight + COMMENT_SCROLL_OFFSET),
|
||||||
|
COMMENT_SCROLL_TIMEOUT
|
||||||
|
);
|
||||||
setPerformedInitialScroll(true);
|
setPerformedInitialScroll(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue