mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-19 07:56:02 +01:00
fix(web/progressbar): fix progressbar getting stuck on screen
Chakra's ScaleFade transition was causing the progress bar not to rerender properly
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { Text, Flex, Box, ScaleFade } from "@chakra-ui/react";
|
import { Text, Flex, Box } from "@chakra-ui/react";
|
||||||
import { useNuiEvent } from "../../hooks/useNuiEvent";
|
import { useNuiEvent } from "../../hooks/useNuiEvent";
|
||||||
import { debugData } from "../../utils/debugData";
|
import { debugData } from "../../utils/debugData";
|
||||||
import { fetchNui } from "../../utils/fetchNui";
|
import { fetchNui } from "../../utils/fetchNui";
|
||||||
@@ -40,7 +40,6 @@ const Progressbar: React.FC = () => {
|
|||||||
useNuiEvent("progressCancel", progressCancel);
|
useNuiEvent("progressCancel", progressCancel);
|
||||||
|
|
||||||
useNuiEvent<Props>("progress", (data) => {
|
useNuiEvent<Props>("progress", (data) => {
|
||||||
if (visible) return;
|
|
||||||
setCancelled(false);
|
setCancelled(false);
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
setLabel(data.label);
|
setLabel(data.label);
|
||||||
@@ -57,7 +56,7 @@ const Progressbar: React.FC = () => {
|
|||||||
alignItems="center"
|
alignItems="center"
|
||||||
>
|
>
|
||||||
<Box width={350}>
|
<Box width={350}>
|
||||||
<ScaleFade in={visible} unmountOnExit>
|
{visible && (
|
||||||
<Box
|
<Box
|
||||||
height={45}
|
height={45}
|
||||||
bg="rgba(0, 0, 0, 0.6)"
|
bg="rgba(0, 0, 0, 0.6)"
|
||||||
@@ -72,11 +71,14 @@ const Progressbar: React.FC = () => {
|
|||||||
sx={
|
sx={
|
||||||
!cancelled
|
!cancelled
|
||||||
? {
|
? {
|
||||||
|
width: "0%",
|
||||||
backgroundColor: "green.400",
|
backgroundColor: "green.400",
|
||||||
animation: `progress-bar linear ${duration}ms`,
|
animation: "progress-bar linear",
|
||||||
|
animationDuration: `${duration}ms`,
|
||||||
}
|
}
|
||||||
: {
|
: {
|
||||||
width: "100%",
|
width: "100%",
|
||||||
|
animationPlayState: "paused",
|
||||||
backgroundColor: "rgb(198, 40, 40)",
|
backgroundColor: "rgb(198, 40, 40)",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -94,7 +96,7 @@ const Progressbar: React.FC = () => {
|
|||||||
{label}
|
{label}
|
||||||
</Text>
|
</Text>
|
||||||
</Box>
|
</Box>
|
||||||
</ScaleFade>
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
</Flex>
|
</Flex>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user