npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@liuyang0826/auto-animate

v0.0.4

Published

auto animate when dom change

Downloads

2

Readme

auto-animate

当元素发生增加、修改、删除时自动增加动画过渡效果。

安装

npm i @liuyang0826/auto-animate

目前提供底层方法 autoAnimate 、vue3的组合式api useAutoAnimate 和自定义指令 vAutoAnimate

用法

  • 使用组合式api的方式
import { useAutoAnimate } from "@liuyang0826/auto-animate/vue"

export default defineComponent({
  setup() {
    const { rootRef } = useAutoAnimate()

    return () => (
      <ul ref={rootRef}>
        <li>1</li>
        <li>2</li>
        <li>3</li>
      </ul>
    )
  }
})
  • 使用自定义指令的方式
import { vAutoAnimate } from "@liuyang0826/auto-animate/vue"

export default defineComponent({
  directives: {
    "auto-animate": vAutoAnimate
  },
  setup() {
    return () => (
      <ul v-auto-animate>
        <li>1</li>
        <li>2</li>
        <li>3</li>
      </ul>
    )
  }
})
  • 你也可以基于 autoAnimate 方法在其他的框架中增加动画。

全局安装组件

// main.ts
import { autoAnimatePlugin } from '@liuyang0826/auto-animate/vue'

app.use(autoAnimatePlugin())

CrossFlip

在vue的包下提供了一个 CrossFlip 组件,用于对任意的元素进行切换时自动添加过渡动画。

import { CrossFlip } from "@liuyang0826/auto-animate/vue"

export default defineComponent({
  setup() {
    const activeRef = ref(1)
    return () => (
      <ul>
        <li>
          <div>1</div>
          {activeRef.value === 1 && <CrossFlip id="line"></CrossFlip>}
        </li>
        <li>
          <div>2</div>
          {activeRef.value === 2 && <CrossFlip id="line"></CrossFlip>}
        </li>
        <li>
          <div>3</div>
          {activeRef.value === 3 && <CrossFlip id="line"></CrossFlip>}
        </li>
      </ul>
    )
  }
})

上面是一个类似tabs的结构,CrossFlip 可以看作是每一项的下边框,当选中项切换时下边框会自动平滑过渡到新的位置。传统做法需要手动获取每一项的宽度等布局信息然后给到下边框的元素进行动画,在某些极端情况下,需要你手动的更新条的位置。使用 CrossFlip 就可以按照正常的流式布局处理。