mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-11-20 18:38:33 +00:00
fix(web/progress): nui callback on progress unmount
fixes an issue where activating 2 progress bars/circles one after another would cause a stuck progress bar. resolves #227
This commit is contained in:
1 parent
3801faf976
commit
672b638ba7
3 files changed
+14
-26
No files matched your search
@@ -52,16 +52,7 @@ const Progressbar: React.FC = () => {
|
||||
const [label, setLabel] = React.useState('');
|
||||
const [duration, setDuration] = React.useState(0);
|
||||
|
||||
const progressComplete = () => {
|
||||
setVisible(false);
|
||||
fetchNui('progressComplete');
|
||||
};
|
||||
|
||||
const progressCancel = () => {
|
||||
setVisible(false);
|
||||
};
|
||||
|
||||
useNuiEvent('progressCancel', progressCancel);
|
||||
useNuiEvent('progressCancel', () => setVisible(false));
|
||||
|
||||
useNuiEvent<ProgressbarProps>('progress', (data) => {
|
||||
setVisible(true);
|
||||
@@ -72,11 +63,11 @@ const Progressbar: React.FC = () => {
|
||||
return (
|
||||
<>
|
||||
<Box className={classes.wrapper}>
|
||||
<ScaleFade visible={visible}>
|
||||
<ScaleFade visible={visible} onExitComplete={() => fetchNui('progressComplete')}>
|
||||
<Box className={classes.container}>
|
||||
<Box
|
||||
className={classes.bar}
|
||||
onAnimationEnd={progressComplete}
|
||||
onAnimationEnd={() => setVisible(false)}
|
||||
sx={{
|
||||
animation: 'progress-bar linear',
|
||||
animationDuration: `${duration}ms`,
|
||||
|
||||
Reference in new issue
Block a user