diff --git a/frontend/src/app/satellites/[satelliteSlug]/_orbitDataGraphComponents/ScrollBarThumb.tsx b/frontend/src/app/satellites/[satelliteSlug]/_orbitDataGraphComponents/ScrollBarThumb.tsx deleted file mode 100644 index 6ffdfbd..0000000 --- a/frontend/src/app/satellites/[satelliteSlug]/_orbitDataGraphComponents/ScrollBarThumb.tsx +++ /dev/null @@ -1,141 +0,0 @@ -"use client"; - -import React, { useState, useEffect, useRef } from "react"; - -export interface ScrollBarThumbProps { - scrollBarThumbWidth: number; - svgContainerRect: { topLeft: number; width: number; height: number }; - /* eslint-disable no-unused-vars*/ - handleChartScroll: ( - thumbX: number, - svgContainerRect: ScrollBarThumbProps["svgContainerRect"], - ) => void; - /* eslint-enable no-unused-vars*/ -} - -const ScrollBarThumb: React.FC = ({ - scrollBarThumbWidth, - svgContainerRect, - handleChartScroll, -}) => { - const isDragging = useRef(false); - { - /* SB is used for ScrollBar */ - } - const [sBThumbX, setSBThumbX] = useState(0); - const thumbRef = useRef(null); - // Distance between the left of the thumb and the mouse click - const distThumbClick = useRef(null); - - /* Be careful useEffect runs before parent props are received */ - useEffect(() => { - const handleMouseUp = () => { - if (thumbRef.current) { - isDragging.current = false; - } - }; - - const handleMouseMove = (e: MouseEvent) => { - if (isDragging.current && thumbRef.current) { - // Scrollbar starts at the right of the svg container and goes to the left by increasing SBThumbX - setSBThumbX(() => { - // Calculating min and max x positions following the SBThumbX axis for moving the thumb with mouse movement - const minX = 0.5; - const maxX = svgContainerRect.width - scrollBarThumbWidth; - // newPos represents left border of the thumb - const newPos = - svgContainerRect.topLeft + - svgContainerRect.width - - scrollBarThumbWidth - - (e.clientX - - (distThumbClick.current - ? distThumbClick.current - : 0)); - - // If mouse movement isn't in the scrollable area - if (newPos <= minX) { - return minX; - } else if (newPos >= maxX) { - return maxX; - } - return newPos; - }); - - // Change the displayed data on the chart - handleChartScroll( - Math.round( - thumbRef.current.getBoundingClientRect().x * 10, - ) / 10, - svgContainerRect, - ); - } - }; - - window.addEventListener("mouseup", handleMouseUp); - window.addEventListener("mousemove", handleMouseMove); - - // Managing the resize of the thumb - if ( - thumbRef.current && - thumbRef.current.getBoundingClientRect().x < - svgContainerRect.topLeft - ) { - setSBThumbX(svgContainerRect.width - scrollBarThumbWidth); - } - - return () => { - window.removeEventListener("mouseup", handleMouseUp); - window.removeEventListener("mousemove", handleMouseMove); - }; - }, [scrollBarThumbWidth, svgContainerRect, handleChartScroll]); - - const handleMouseDown = ( - e: React.MouseEvent, - ) => { - // If the thumb is clicked with left mouse button, we start dragging - if (thumbRef.current && e.button === 0) { - isDragging.current = true; - distThumbClick.current = - e.clientX - thumbRef.current.getBoundingClientRect().left; - } - }; - - return ( - <> - - - - - - - ); -}; - -export default ScrollBarThumb; diff --git a/frontend/src/app/satellites/[satelliteSlug]/orbitDataGraph.tsx b/frontend/src/app/satellites/[satelliteSlug]/orbitDataGraph.tsx index 5c2ee6e..644e69e 100644 --- a/frontend/src/app/satellites/[satelliteSlug]/orbitDataGraph.tsx +++ b/frontend/src/app/satellites/[satelliteSlug]/orbitDataGraph.tsx @@ -60,6 +60,7 @@ const OrbitDataGraph: React.FC = ({ orbitalData }) => { fontSize: "14px", }, }, + opposite: false, // Left side }, // Second Y-axis (right) - Eccentricity { @@ -88,6 +89,7 @@ const OrbitDataGraph: React.FC = ({ orbitalData }) => { fontSize: "14px", }, }, + opposite: false, // Left side }, ], series: [