From ef9b67217948d8476a9a73ce5125929dff46b7c9 Mon Sep 17 00:00:00 2001 From: ascibisz Date: Mon, 10 Jun 2024 11:34:55 -0700 Subject: [PATCH 1/2] remove extra on change / after change code that doesn't seem necessary anymore --- src/components/PlaybackControls/index.tsx | 31 +---------------------- 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/src/components/PlaybackControls/index.tsx b/src/components/PlaybackControls/index.tsx index e4c92cf0..066fc58a 100644 --- a/src/components/PlaybackControls/index.tsx +++ b/src/components/PlaybackControls/index.tsx @@ -49,36 +49,8 @@ const PlayBackControls = ({ timeUnits, isEmpty, }: PlayBackProps): JSX.Element => { - // Where to resume playing if simulation was playing before scrubbing - const [timeToResumeAfterScrubbing, setTimeToResumeAfterScrubbing] = - useState(-1); const [timeInput, setTimeInput] = useState(firstFrameTime); - // - Gets called once when the user clicks on the slider to skip to a specific time - // - Gets called multiple times when user is scrubbing (every time the play head - // passes through a time value associated with a frame) - const handleTimeChange = (sliderValue: number): void => { - onTimeChange(sliderValue); - if (isPlaying) { - // Need to save the sliderValue as timeToResumeAfterScrubbing to use in handleSliderMouseUp, - // because the sliderValue argument available in handleSliderMouseUp is not accurate - // when the time between mouse down and mouse up is short. - setTimeToResumeAfterScrubbing(sliderValue); - pauseHandler(); - } else if (timeToResumeAfterScrubbing >= 0) { - // Update value if user is still dragging - setTimeToResumeAfterScrubbing(sliderValue); - } - }; - - const handleSliderMouseUp = (): void => { - // Resume playing if simulation was playing before - if (timeToResumeAfterScrubbing >= 0) { - playHandler(timeToResumeAfterScrubbing); - setTimeToResumeAfterScrubbing(-1); - } - }; - // Called after every keystroke const handleTimeInputChange = (userInput: number | null): void => { if (userInput !== null) { @@ -148,8 +120,7 @@ const PlayBackControls = ({ Date: Mon, 10 Jun 2024 11:35:27 -0700 Subject: [PATCH 2/2] don't trigger buffering when we're jumping around --- src/containers/ViewerPanel/index.tsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/containers/ViewerPanel/index.tsx b/src/containers/ViewerPanel/index.tsx index dd3f229c..236d116e 100644 --- a/src/containers/ViewerPanel/index.tsx +++ b/src/containers/ViewerPanel/index.tsx @@ -348,7 +348,6 @@ class ViewerPanel extends React.Component { lastFrameTime, timeStep, isBuffering, - setBuffering, } = this.props; if (isBuffering) { return; @@ -361,8 +360,6 @@ class ViewerPanel extends React.Component { if (isTimeGreaterThanLastFrameTime || isTimeLessThanFirstFrameTime) { return; } - - setBuffering(true); simulariumController.gotoTime(time); }