fix: remove switch animation
All checks were successful
Deploy to VPS (dist) / deploy (push) Successful in 1m41s
All checks were successful
Deploy to VPS (dist) / deploy (push) Successful in 1m41s
This commit is contained in:
@@ -45,6 +45,7 @@
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
width: 50%;
|
||||||
border-radius: 9999px;
|
border-radius: 9999px;
|
||||||
z-index: 0;
|
z-index: 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { motion, type HTMLMotionProps } from "motion/react";
|
|||||||
|
|
||||||
import classes from "./SwitchInput.module.css";
|
import classes from "./SwitchInput.module.css";
|
||||||
import tg from "@/tg";
|
import tg from "@/tg";
|
||||||
|
import { useRef } from "react";
|
||||||
|
|
||||||
type Props = Omit<HTMLMotionProps<"div">, "className" | "onChange"> & {
|
type Props = Omit<HTMLMotionProps<"div">, "className" | "onChange"> & {
|
||||||
value?: boolean | null;
|
value?: boolean | null;
|
||||||
@@ -15,7 +16,8 @@ type Props = Omit<HTMLMotionProps<"div">, "className" | "onChange"> & {
|
|||||||
|
|
||||||
export default function SwitchInput({ value, onChange, className, ...props }: Props) {
|
export default function SwitchInput({ value, onChange, className, ...props }: Props) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const selectedIndex = value != null ? (value ? 0 : 1) : -1;
|
const selectedIndex = value != null ? (value ? 0 : 1) : 0;
|
||||||
|
const selectedIndexRef = useRef(selectedIndex);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ContentSurface
|
<ContentSurface
|
||||||
@@ -45,12 +47,8 @@ export default function SwitchInput({ value, onChange, className, ...props }: Pr
|
|||||||
{selectedIndex >= 0 && (
|
{selectedIndex >= 0 && (
|
||||||
<LightSurface
|
<LightSurface
|
||||||
className={classes.thumb}
|
className={classes.thumb}
|
||||||
initial={{ scale: 0.5 }}
|
initial={{ left: `${selectedIndexRef.current * 50}%` }}
|
||||||
animate={{
|
animate={{ left: `${selectedIndex * 50}%` }}
|
||||||
left: `${selectedIndex * 50}%`,
|
|
||||||
width: "50%",
|
|
||||||
scale: 1,
|
|
||||||
}}
|
|
||||||
transition={{ type: "spring", stiffness: 500, damping: 35 }}
|
transition={{ type: "spring", stiffness: 500, damping: 35 }}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
background-image: url("./assets/main-bg.png");
|
background-image: url("./assets/main-bg.svg");
|
||||||
background-size: auto 101%;
|
background-size: auto 101%;
|
||||||
background-position: center;
|
background-position: center;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|||||||
Reference in New Issue
Block a user