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

fix api reset #318

Merged
merged 1 commit into from
Apr 6, 2024
Merged
Changes from all 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
7 changes: 6 additions & 1 deletion src/components/pages/sandbox/roulette/Roulette.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import AliceCarousel from '../../../../lib/react-alice-carousel';
import { shuffleArray, genItems, genRandomInt } from './Roulette.utils';
import type { Props, Item } from './Roulette.types';

let timeoutId: null | NodeJS.Timeout = null;

const responsive = {
0: { items: 1 },
640: { items: 3 },
Expand All @@ -33,7 +35,7 @@ function getOffset(itemsOnScreen: number) {

function loadWinner() {
return new Promise<{ id: number }>((resolve) => {
setTimeout(() => resolve({ id: genRandomInt() }), 2_000);
timeoutId = setTimeout(() => resolve({ id: genRandomInt() }), 2_000);
});
}

Expand Down Expand Up @@ -125,9 +127,12 @@ export default function SandboxPage(props: Partial<Props>) {
<button
className="text"
onClick={() => {
if (timeoutId) clearTimeout(timeoutId);
setKey(key + 1);
setWinner(null);
setActive(itemsPadding);
setWinnerId(null);
setSetIsWinnerLoading(false);
setIsWinnerHighlighted(false);
setIsRouletteAnimationProcess(false);
}}
Expand Down