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

@ntbl/animation

v0.0.1

Published

一个基于 anime.js 的动画库,更加便捷与实用。

Downloads

1

Readme

animation

GitHub npm MIT

animation,一个基于 anime.js 的动画库,更加便捷与实用。

在线 Dome

Installation

npm i @ntbl/animation --save

Usage

import animation from '@ntbl/animation'

animation 是对 anime.js 的二次包装,内置了一些便捷实用的动画类型、并支持动画联动、正反播放切换和隐藏 dom。关于 animation 的基础使用,请参考 anime.js

本文档,只会涉及到 animation 自己封装和设计的概念与功能。它用起来是简单。

动画类型

animation 提供了以下动画类型:

  • sideLeft
  • sideRight
  • sideTop
  • sideBottom
  • fadeIn
  • fadeOut

通过 type 属性指定需要使用的动画即可。

animation({
    targets: '#box',
    type: 'sideLeft'
  })

另外,不同类型的动画还可以配合使用。(不同类型指的是 sideTop 和 fadeIn 是不同类型的,而 sideTop 和 sideLeft 是同类型)

animation({
    targets: '#box',
    type: ['sideLeft', 'fadeIn']
  })

动画控制

anime.js 实例的 seek() 方法,可用于精确控制动画进行,比如配合手势库,可以实现原生应用上抽屉导航与手指在同步屏幕上移动。参考

动画联动

anime.js 可以使用 timeline 实现时间轴动画,在此基础上 animation 简化和统一了用法,增加了联动。联动顾名思义就是同时进行二个或多个动画,并且可以配合动画控制,做出和原生应用一致的动画体验。

默认情况下,timeline 是按照动画先后顺序执行(即所谓时间轴动画),在 animation 中,通过设置 linkage=true 即可开启联动。

animation({
    // 开启联动
    linkage: true,
    // 在时间线上指定每个元素的动画
    timeline: [
      { targets: '#box1', type: 'sideLeft'},
      { targets: '#box2', type: 'sideTop'},
      { targets: '#box3', type: 'sideBottom'},
      { targets: '#box4', type: 'sideRight'},
    ],
  })

动画状态切换和 dom 移除

类似 vue.js 的 transition 组件,通过 v-show 可以轻松使用动画的正向反向状态的切换,并且在动画 enter 时和 leave 后移除和显式(调整 css 的 display 值) dom 元素。animation 也为你提供了类似的方法 toggle()

const ani = animation({
    // 开启 dom 的移除和显式
    dom: true,
    type: 'sideLeft'
})
  
// 将会正向反向互相进行动画  
ani.toggle()