@bryce-loskie/frame
TypeScript icon, indicating that this package has built-in type declarations

0.2.4 • Public • Published

frame

Animation util for vue based on Motion One

NPM version

Get Started

pnpm i @bryce-loskie/frame

Usage

1. Framer component

<template>
  <Framer appear :variants="variants">
    <div v-if="isShow" i-carbon-windy-snow text-4xl inline-block />
  </Framer>
</template>

<script lang="ts" setup>
  import { Framer, defineVariants, spring } from '@bryce-loskie/frame'

  const variants = defineVariants({
    enter: {
      x: [-200, 0],
      scale: [1, 2],
      options: {
        easing: spring(),
      },
    },
    leave: {
      x: 200,
      opacity: 0.5,
      scale: 1,
    },
  })
</script>

2. useFrame hook

<template>
  <div ref="elRef" i-carbon-windy-snow text="4xl sky-500" inline-block />
  <button class="m-3 text-sm btn capitalize" @click="animation?.reverse()">
    reverse
  </button>
</template>

<script lang="ts" setup>
  import { useFrame, spring } from '@bryce-loskie/frame'

  const elRef = ref()
  const animation = useFrame(
    elRef,
    {
      x: [-200, 0],
      scale: [1, 2],
    },
    {
      easing: spring(),
    }
  )
</script>

3. directive

<template>
  <div v-frame="keyframes" i-carbon-windy-snow text="4xl sky-500" inline-block />
</template>

<script lang="ts" setup>
  import { defineDirective, defineFrame, spring } from '@bryce-loskie/frame'

  const vFrame = defineDirective()
  const keyframes = defineFrame({
    x: [-200, 0],
    scale: [1, 2],
  }, {
    easing: spring(),
  })
</script>

License

MIT License © 2022 guygubaby

TODO:

  • [x] Add Transition component
  • [x] Add useFrame hook
  • [x] Add directive
  • [x] Export animate,spring,stagger fn

Dependencies (1)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i @bryce-loskie/frame

    Weekly Downloads

    1

    Version

    0.2.4

    License

    MIT

    Unpacked Size

    93.5 kB

    Total Files

    7

    Last publish

    Collaborators

    • guygubaby