mirror of
https://github.com/owncast/owncast.git
synced 2024-11-29 11:39:08 +03:00
removed timers from component in favor of css transition (#2769)
* removed timers from component in favor of css transition * removed semibold text --------- Co-authored-by: Gabe Kangas <gabek@real-ity.com>
This commit is contained in:
parent
cd2cd55549
commit
3629f318e8
2 changed files with 16 additions and 15 deletions
|
@ -4,13 +4,17 @@
|
|||
width: 100%;
|
||||
justify-content: center;
|
||||
position: absolute;
|
||||
bottom: 50px;
|
||||
bottom: 75px;
|
||||
color: var(--theme-color-components-text-on-light);
|
||||
|
||||
button {
|
||||
background-color: var(--theme-color-background-light);
|
||||
z-index: 9999;
|
||||
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.1), 0 1px 5px 0 rgba(0, 0, 0, 0.12);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
opacity: 0;
|
||||
animation: show 250ms forwards ease-in-out 500ms;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,3 +42,13 @@
|
|||
.chatTextField {
|
||||
border-top: 1px solid lightgray;
|
||||
}
|
||||
|
||||
@keyframes show {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(5px);
|
||||
} to {
|
||||
opacity: 1;
|
||||
transform: translateY(0px);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,22 +99,14 @@ export const ChatContainer: FC<ChatContainerProps> = ({
|
|||
const [isAtBottom, setIsAtBottom] = useState(false);
|
||||
|
||||
const chatContainerRef = useRef(null);
|
||||
const showScrollToBottomButtonDelay = useRef(null);
|
||||
const scrollToBottomDelay = useRef(null);
|
||||
|
||||
const collapsedMessageIds = new Set<string>();
|
||||
|
||||
const setShowScrolltoBottomButtonWithDelay = (show: boolean) => {
|
||||
showScrollToBottomButtonDelay.current = setTimeout(() => {
|
||||
setShowScrollToBottomButton(show);
|
||||
}, 1500);
|
||||
};
|
||||
|
||||
useEffect(
|
||||
() =>
|
||||
// Clear the timer when the component unmounts
|
||||
() => {
|
||||
clearTimeout(showScrollToBottomButtonDelay.current);
|
||||
clearTimeout(scrollToBottomDelay.current);
|
||||
},
|
||||
[],
|
||||
|
@ -213,7 +205,6 @@ export const ChatContainer: FC<ChatContainerProps> = ({
|
|||
|
||||
const scrollChatToBottom = (ref, behavior = 'smooth') => {
|
||||
clearTimeout(scrollToBottomDelay.current);
|
||||
clearTimeout(showScrollToBottomButtonDelay.current);
|
||||
scrollToBottomDelay.current = setTimeout(() => {
|
||||
ref.current?.scrollToIndex({
|
||||
index: messages.length - 1,
|
||||
|
@ -230,7 +221,6 @@ export const ChatContainer: FC<ChatContainerProps> = ({
|
|||
useEffect(() => {
|
||||
setTimeout(() => {
|
||||
scrollChatToBottom(chatContainerRef, 'auto');
|
||||
setShowScrolltoBottomButtonWithDelay(false);
|
||||
}, 500);
|
||||
}, []);
|
||||
|
||||
|
@ -246,14 +236,11 @@ export const ChatContainer: FC<ChatContainerProps> = ({
|
|||
itemContent={(index, message) => getViewForMessage(index, message)}
|
||||
initialTopMostItemIndex={messages.length - 1}
|
||||
followOutput={() => {
|
||||
clearTimeout(showScrollToBottomButtonDelay.current);
|
||||
|
||||
if (isAtBottom) {
|
||||
setShowScrollToBottomButton(false);
|
||||
scrollChatToBottom(chatContainerRef, 'auto');
|
||||
return 'smooth';
|
||||
}
|
||||
setShowScrolltoBottomButtonWithDelay(true);
|
||||
|
||||
return false;
|
||||
}}
|
||||
|
@ -265,7 +252,7 @@ export const ChatContainer: FC<ChatContainerProps> = ({
|
|||
if (bottom) {
|
||||
setShowScrollToBottomButton(false);
|
||||
} else {
|
||||
setShowScrolltoBottomButtonWithDelay(true);
|
||||
setShowScrollToBottomButton(true);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
|
|
Loading…
Reference in a new issue