Skip to content

Commit 118811f

Browse files
committed
Tweak the palifico animation
1 parent 4898f81 commit 118811f

File tree

1 file changed

+24
-32
lines changed

1 file changed

+24
-32
lines changed

ui/src/Board.tsx

Lines changed: 24 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@ import "tippy.js/dist/tippy.css";
22

33
import { msg, Trans } from "@lingui/macro";
44
import { useLingui } from "@lingui/react";
5-
import {
6-
animated,
7-
config as springConfig,
8-
useSpring,
9-
useTransition,
10-
} from "@react-spring/web";
5+
import { animated, config as springConfig, useSpring } from "@react-spring/web";
116
import Tippy from "@tippyjs/react";
127
import classNames from "classnames";
138
import { ReactNode, useEffect, useState } from "react";
@@ -458,36 +453,33 @@ const WildsInfo = () => {
458453
palifico &&
459454
(step === "play" || (step === "revealed" && (!iHaveRolled || !iAmAlive)));
460455

461-
const palificoTrans = useTransition(shouldSeePalifico, {
456+
const style = useSpring({
457+
opacity: shouldSeePalifico ? 1 : 0,
458+
transform: shouldSeePalifico
459+
? "scale(1) rotate(-5deg)"
460+
: "scale(0) rotate(12deg)",
461+
immediate: !shouldSeePalifico,
462462
config: {
463-
tension: 200,
464-
friction: 22,
465-
clamp: true,
463+
tension: 500,
464+
friction: 12,
465+
precision: 0.02,
466466
},
467-
from: { opacity: 0, transform: "scale(4) rotate(12deg)" },
468-
enter: { opacity: 1, transform: "scale(1) rotate(-5deg)" },
469-
leave: { opacity: 0 },
470467
});
471468

472469
return (
473470
<div className="w-full h-full flex justify-end">
474-
{palificoTrans(
475-
(style, item) =>
476-
item && (
477-
<div className="ml auto w-24 h-full relative">
478-
{/* absolute so that it doesn't influence the height of the container. */}
479-
<div className="absolute right-0 top-0 bottom-0 flex items-center">
480-
<animated.div
481-
className="my-auto ml-auto mr-1 opacity-0"
482-
style={{ ...style }}
483-
>
484-
<Palifico />
485-
</animated.div>
486-
</div>
487-
</div>
488-
),
489-
)}
490-
<div className="flex-1 w-0 max-w-60 flex">
471+
<div className="ml auto w-24 h-full relative">
472+
{/* absolute so that it doesn't influence the height of the container. */}
473+
<div className="absolute right-0 top-0 bottom-0 flex items-center">
474+
<animated.div
475+
className="my-auto ml-auto mr-1 opacity-0"
476+
style={{ ...style }}
477+
>
478+
<Palifico />
479+
</animated.div>
480+
</div>
481+
</div>
482+
<div className="flex">
491483
<div className="ml-auto my-auto inline-block text-gray-600 py-0.5 pl-1 pr-1.5 leading-5">
492484
{shouldSeePalifico ? (
493485
<Trans>
@@ -879,13 +871,13 @@ const Board = () => {
879871
`}
880872
>
881873
<Header />
882-
<div className="panel">
874+
<div className="panel pb-1 vsm:pb-2.5">
883875
<div className="space-y-1 vsm:space-y-1.5">
884876
{playerOrder.map((u) => (
885877
<Player userId={u} key={u} />
886878
))}
887879
</div>
888-
<div className="h-11 vsm:mt-2 flex items-center">
880+
<div className="h-11 mt-1 vsm:mt-2 flex items-center">
889881
<WildsInfo />
890882
</div>
891883
</div>

0 commit comments

Comments
 (0)