Files
ThreadNet-Web/src/components/views/elements/ProgressBar.tsx
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

28 lines
954 B
TypeScript
Raw Normal View History

2020-06-26 14:02:36 +01:00
/*
2024-09-09 14:57:16 +01:00
Copyright 2024 New Vector Ltd.
Copyright 2020-2022 The Matrix.org Foundation C.I.C.
2020-06-26 14:02:36 +01:00
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
2024-09-09 14:57:16 +01:00
Please see LICENSE files in the repository root for full details.
2020-06-26 14:02:36 +01:00
*/
import React from "react";
2022-07-29 13:43:29 +02:00
import { useSmoothAnimation } from "../../../hooks/useSmoothAnimation";
2020-06-26 14:02:36 +01:00
interface IProps {
value: number;
max: number;
2022-07-29 13:43:29 +02:00
animated?: boolean;
2020-06-26 14:02:36 +01:00
}
2022-07-29 13:43:29 +02:00
const PROGRESS_BAR_ANIMATION_DURATION = 300;
const ProgressBar: React.FC<IProps> = ({ value, max, animated = true }) => {
2022-07-29 13:43:29 +02:00
// Animating progress bars via CSS transition isnt possible in all of our supported browsers yet.
// As workaround, were using animations through JS requestAnimationFrame
const currentValue = useSmoothAnimation(0, value, animated ? PROGRESS_BAR_ANIMATION_DURATION : 0);
2022-07-29 13:43:29 +02:00
return <progress className="mx_ProgressBar" max={max} value={currentValue} />;
2020-06-26 14:02:36 +01:00
};
export default ProgressBar;