"updated overall animation logics"

This commit is contained in:
SreeNath14
2025-04-04 18:02:53 +05:30
parent 280fe59a14
commit c5ca0da1c5
8 changed files with 367 additions and 1540 deletions

View File

@@ -1,19 +1,28 @@
import React, { useState, useRef, useEffect } from "react";
import { ExitIcon, PlayStopIcon, ResetIcon } from "../../icons/SimulationIcons";
import { usePlayButtonStore } from "../../../store/usePlayButtonStore";
import {
useAnimationPlaySpeed,
usePauseButtonStore,
usePlayButtonStore,
useResetButtonStore,
} from "../../../store/usePlayButtonStore";
const SimulationPlayer: React.FC = () => {
const [speed, setSpeed] = useState<number>(1);
const { speed, setSpeed } = useAnimationPlaySpeed();
const [playSimulation, setPlaySimulation] = useState(false);
const { setIsPlaying } = usePlayButtonStore();
const sliderRef = useRef<HTMLDivElement>(null);
const isDragging = useRef(false);
const { isPaused, setIsPaused } = usePauseButtonStore();
const { isReset, setReset } = useResetButtonStore();
// Button functions
const handleReset = () => {
setReset(true);
setSpeed(1);
};
const handlePlayStop = () => {
setIsPaused(!isPaused);
setPlaySimulation(!playSimulation);
};
const handleExit = () => {
@@ -27,7 +36,7 @@ const SimulationPlayer: React.FC = () => {
};
const calculateHandlePosition = () => {
return ((speed - 0.5) / (50 - 0.5)) * 100;
return ((speed - 0.5) / (8 - 0.5)) * 100;
};
const handleMouseDown = () => {
@@ -115,7 +124,7 @@ const SimulationPlayer: React.FC = () => {
<input
type="range"
min="0.5"
max="50"
max="8"
step="0.1"
value={speed}
onChange={handleSpeedChange}
@@ -123,7 +132,7 @@ const SimulationPlayer: React.FC = () => {
/>
</div>
</div>
<div className="max-value">50x</div>
<div className="max-value">8x</div>
</div>
</div>
</div>