From 186bee9ba61f9bbce8a013d557c770be6e32c99d Mon Sep 17 00:00:00 2001 From: John Doe Date: Sat, 9 Sep 2023 16:46:36 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Refactor=20animation=20variants?= =?UTF-8?q?=20=F0=9F=9B=A0=EF=B8=8F=20Improve=20code=20readability=20and?= =?UTF-8?q?=20maintainability=20=F0=9F=93=A6=20Export=20variants=20functio?= =?UTF-8?q?n=20for=20reuse=20=F0=9F=94=8D=20Adjust=20default=20parameters?= =?UTF-8?q?=20for=20flexibility=20=F0=9F=8C=9F=20Enhance=20animation=20log?= =?UTF-8?q?ic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/animationVariants.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/utils/animationVariants.ts diff --git a/src/utils/animationVariants.ts b/src/utils/animationVariants.ts new file mode 100644 index 0000000..ce38e17 --- /dev/null +++ b/src/utils/animationVariants.ts @@ -0,0 +1,18 @@ +export const variants = (x = 1000, opacity = 0) => ({ + enter: (direction: number) => { + return { + x: direction > 0 ? x : -x, + opacity, + }; + }, + center: { + x: 0, + opacity: 1, + }, + exit: (direction: number) => { + return { + x: direction < 0 ? x : -x, + opacity, + }; + }, +});