From 943b47ab0949bf9a1b9d476add0b33584ca0c8b2 Mon Sep 17 00:00:00 2001 From: rasguy92 Date: Sat, 11 Nov 2023 10:00:39 +0700 Subject: [PATCH] feat: remove auto roll from web version --- src/components/Dice/animations.ts | 6 ++++-- src/components/LandingPageHero/index.tsx | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/Dice/animations.ts b/src/components/Dice/animations.ts index 7e3bf05..67bb117 100644 --- a/src/components/Dice/animations.ts +++ b/src/components/Dice/animations.ts @@ -6,7 +6,7 @@ export function useRoll(diceRef: any,) { const triggerRoll = () => setStrigger((s: boolean) => !s); function roll() { - gsap.set("g#all-sides", {y: "0"}) + gsap.set("g#all-sides", { y: "0" }) const tl = gsap.timeline(); tl.to("g#all-sides", { duration: 2, @@ -16,9 +16,11 @@ export function useRoll(diceRef: any,) { }) } useLayoutEffect(()=> { - const ctx = gsap.context(() => { + + const ctx = gsap.context(() => { roll(); }, diceRef); + return () => ctx.revert(); }, [trigger]); diff --git a/src/components/LandingPageHero/index.tsx b/src/components/LandingPageHero/index.tsx index 6d6809d..9c896df 100644 --- a/src/components/LandingPageHero/index.tsx +++ b/src/components/LandingPageHero/index.tsx @@ -1,7 +1,7 @@ import { useRef } from 'react'; import { PlayGameContainer } from "../LandingPageHeroSection/types"; import { Dice } from "../Dice"; -import { useRoll, useAutoRoll } from "../Dice/animations"; +import { useRoll } from "../Dice/animations"; import { LeftPlayerCard, RightPlayerCard } from "../LandingHeroPlayerCard"; import Button from "../Button"; import 'twin.macro'; @@ -9,7 +9,7 @@ import 'twin.macro'; const LandingPageHero = () => { const diceRef = useRef(null); const triggerDice = useRoll(diceRef); - useAutoRoll(diceRef); +// useAutoRoll(diceRef); return (