snapshot of https://github.com/jitsi/jitsi-meet.git @ fd1749dd28f4138aa80234fc7f311b19aaffa0e7 (2026-09-15)
This commit is contained in:
39
react/features/base/ui/components/web/DialogTransition.tsx
Normal file
39
react/features/base/ui/components/web/DialogTransition.tsx
Normal file
@@ -0,0 +1,39 @@
|
||||
import React, { ReactElement, useEffect, useState } from 'react';
|
||||
|
||||
export const DialogTransitionContext = React.createContext({ isUnmounting: false });
|
||||
|
||||
type TimeoutType = ReturnType<typeof setTimeout>;
|
||||
|
||||
const DialogTransition = ({ children }: { children: ReactElement | null; }) => {
|
||||
const [ childrenToRender, setChildrenToRender ] = useState(children);
|
||||
const [ isUnmounting, setIsUnmounting ] = useState(false);
|
||||
const [ timeoutID, setTimeoutID ] = useState<TimeoutType | undefined>(undefined);
|
||||
|
||||
useEffect(() => {
|
||||
if (children === null) {
|
||||
setIsUnmounting(true);
|
||||
if (typeof timeoutID === 'undefined') {
|
||||
setTimeoutID(setTimeout(() => {
|
||||
setChildrenToRender(children);
|
||||
setIsUnmounting(false);
|
||||
setTimeoutID(undefined);
|
||||
}, 150));
|
||||
}
|
||||
} else {
|
||||
if (typeof timeoutID !== 'undefined') {
|
||||
clearTimeout(timeoutID);
|
||||
setTimeoutID(undefined);
|
||||
setIsUnmounting(false);
|
||||
}
|
||||
setChildrenToRender(children);
|
||||
}
|
||||
}, [ children ]);
|
||||
|
||||
return (
|
||||
<DialogTransitionContext.Provider value = {{ isUnmounting }}>
|
||||
{childrenToRender}
|
||||
</DialogTransitionContext.Provider>
|
||||
);
|
||||
};
|
||||
|
||||
export default DialogTransition;
|
||||
Reference in New Issue
Block a user