From 11a8bd29d0354115491214467ae92a6fce67af27 Mon Sep 17 00:00:00 2001 From: Katja Lutz Date: Wed, 22 Jun 2022 21:25:54 +0200 Subject: [PATCH] feat: implement autoAnimate directive --- src/directives/autoAnimate.tsx | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/directives/autoAnimate.tsx diff --git a/src/directives/autoAnimate.tsx b/src/directives/autoAnimate.tsx new file mode 100644 index 0000000..3aa98ef --- /dev/null +++ b/src/directives/autoAnimate.tsx @@ -0,0 +1,21 @@ +import autoAnimate_ from "@formkit/auto-animate"; +import { onMount } from "solid-js"; + +// https://auto-animate.formkit.com/ + +export const autoAnimate = ( + el: HTMLElement, + config?: () => Parameters[1] +) => { + onMount(function () { + autoAnimate_(el, config != null ? config() : undefined); + }); +}; + +declare module "solid-js" { + namespace JSX { + interface Directives { + autoAnimate: Parameters[1] | boolean; + } + } +}