diff --git a/src/react_app/src/components/leaderboards_components/threshold_selector.jsx b/src/react_app/src/components/leaderboards_components/threshold_selector.jsx
index 1025f79..eb357ac 100644
--- a/src/react_app/src/components/leaderboards_components/threshold_selector.jsx
+++ b/src/react_app/src/components/leaderboards_components/threshold_selector.jsx
@@ -15,10 +15,22 @@ const ThresholdSelector = ({ threshold, setThreshold }) => {
const handleMouseDown = (event) => {
event.preventDefault();
setIsDragging(true);
+ updateValueFromEvent(event);
};
const handleMouseMove = (event) => {
- if (isDragging && containerRef.current && circleRef.current) {
+ if (isDragging) {
+ updateValueFromEvent(event);
+ }
+ };
+
+ const handleMouseUp = () => {
+ setIsDragging(false);
+ setThreshold(dragValue);
+ };
+
+ const updateValueFromEvent = (event) => {
+ if (containerRef.current) {
const containerRect = containerRef.current.getBoundingClientRect();
const newX = event.clientX - containerRect.left;
const containerWidth = containerRect.width;
@@ -28,11 +40,6 @@ const ThresholdSelector = ({ threshold, setThreshold }) => {
}
};
- const handleMouseUp = () => {
- setIsDragging(false);
- setThreshold(dragValue);
- };
-
useEffect(() => {
if (isDragging) {
window.addEventListener("mousemove", handleMouseMove);
@@ -48,10 +55,22 @@ const ThresholdSelector = ({ threshold, setThreshold }) => {
const handleTouchStart = (event) => {
event.preventDefault();
setIsDragging(true);
+ updateValueFromTouchEvent(event);
};
const handleTouchMove = (event) => {
- if (isDragging && containerRef.current && circleRef.current) {
+ if (isDragging) {
+ updateValueFromTouchEvent(event);
+ }
+ };
+
+ const handleTouchEnd = () => {
+ setIsDragging(false);
+ setThreshold(dragValue);
+ };
+
+ const updateValueFromTouchEvent = (event) => {
+ if (containerRef.current) {
const containerRect = containerRef.current.getBoundingClientRect();
const newX = event.touches[0].clientX - containerRect.left;
const containerWidth = containerRect.width;
@@ -61,11 +80,6 @@ const ThresholdSelector = ({ threshold, setThreshold }) => {
}
};
- const handleTouchEnd = () => {
- setIsDragging(false);
- setThreshold(dragValue);
- };
-
useEffect(() => {
if (isDragging) {
window.addEventListener("touchmove", handleTouchMove);
@@ -85,7 +99,12 @@ const ThresholdSelector = ({ threshold, setThreshold }) => {
>
{t("threshold_select")}
-
+
{
diff --git a/src/react_app/src/components/leaderboards_components/weapon_controls.jsx b/src/react_app/src/components/leaderboards_components/weapon_controls.jsx
index 23205a5..a3c5551 100644
--- a/src/react_app/src/components/leaderboards_components/weapon_controls.jsx
+++ b/src/react_app/src/components/leaderboards_components/weapon_controls.jsx
@@ -112,21 +112,23 @@ const WeaponLeaderboardControls = ({
>
)}
-
+
+
+