Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shorten duration of replay rewind animation #743

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@ function acceleratedRewind(
setTimeCallback: (time: number) => void,
readyCallback: () => void
) {
const rewindTimeSec = 1.6;
// If REPLAY_REWIND_INTRODUCE_KEY is missing in global state, we assume that the
// replay rewind feature has not been introduced. In this case, we use a longer
// rewind time to help users more easily understand the rewind feature.
const REPLAY_REWIND_INTRODUCE_KEY = "wasReplayRewindIntroduced";
const wasRewindIntroduced = localStorage.getItem(REPLAY_REWIND_INTRODUCE_KEY) ?? false;

const rewindTimeSec = wasRewindIntroduced ? 0.6 : 1.6;
const v0 = 0.1;
const vFinal = 2 / rewindTimeSec - v0;
const acc = (vFinal - v0) / rewindTimeSec;
Expand Down Expand Up @@ -47,6 +52,10 @@ function acceleratedRewind(
}
}
requestAnimationFrame(frame);

if (!wasRewindIntroduced) {
localStorage.setItem(REPLAY_REWIND_INTRODUCE_KEY, "true");
}
}

function isVideoPlaying(videoElement: HTMLVideoElement) {
Expand Down