0.3.0 • Published 3 months ago

solid-auto-animate v0.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

solid-auto-animate

SolidJS bindings for FormKit's AutoAnimate

NPM JavaScript Style GuideOpen in CodeSandbox

Install

npm install --save solid-js @formkit/auto-animate solid-auto-animate
yarn add solid-js @formkit/auto-animate solid-auto-animate
pnpm add solid-js @formkit/auto-animate solid-auto-animate

Usage

As directive

import { createSignal } from 'solid-js';
import { autoAnimate } from 'solid-auto-animate';

function App() {
  // Required to prevent TS from removing the directive
  autoAnimate;

  const [items, setItems] = createSignal([0, 1, 2]);
  const add = () => setItems((current) => [...current, current.length]);

  return (
    <>
      <ul use:autoAnimate={/* optional config */}>
        <For each={items()}>
          {(item) => <li>{item}</li>}
        </For>
      </ul>
      <button onClick={add}>Add number</button>
    </>
  );
}

As primitive

import { createSignal } from 'solid-js';
import { useAutoAnimate } from 'solid-auto-animate';

function App() {
  const [items, setItems] = createSignal([0, 1, 2]);
  const add = () => setItems((current) => [...current, current.length])

  let parent;

  useAutoAnimate(() => parent, /* optional config */)

  return (
    <>
      <ul ref={parent}>
        <For each={items()}>
          {(item) => <li>{item}</li>}
        </For>
      </ul>
      <button onClick={add}>Add number</button>
    </>
  );
}

License

MIT © lxsmnsyc

0.3.0

3 months ago

0.2.0

2 years ago

0.1.0

2 years ago