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

@dao3fun/mine-motion

v1.0.5

Published

简单的动画库,可以用于Arena客户端UI的缓动、变色等各种动画效果。

Downloads

436

Readme

MineMotion

简单的动画库,可以用于Arena客户端UI的缓动、变色等各种动画效果。

Example

const box = UiBox.create();
box.size.offset.x = 100;
box.size.offset.y = 100;
box.backgroundColor.r = 255;
box.backgroundColor.g = 0;
box.backgroundColor.b = 0;
box.parent = ui;
;(async function(){
  // 在1s内移动到(300, 200)
  await MineMotion.fromTo({
    obj:       box.position.offset, // 要进行变换的对象
    duraction: 1000,                // 变换时间,单位为ms 
    from:      { x: 0, y: 0 },      // 起始值
    to:        { x: 300, y: 200 },  // 目标值
    ease:      Ease.easeInOut       // 缓动函数
  }).wait;

  // 变色的同时移动到(0, 0)
  // 这里不await,否则会先变色后移动
  MineMotion.fromTo({
    obj:      box.backgroundColor, 
    duration: 1000, 
    from:     { r: 255, g: 0, b: 0 }, 
    to:       { r: 0, g: 255, b: 0 }, 
    ease:     Ease.easeInOut
  });
  await MineMotion.fromTo({
    obj:      box.position.offset,
    duration: 1000,
    from:     { x: 300, y: 200 },
    to:       { x: 0, y: 0 },
    // 默认使用线性缓动函数
  }).wait;
})();

效果:

API

MineMotion.fromTo(obj, duration, start, end, ease)

创建一个动画,从start到end,在duration时间内完成。

definition

static fromTo<T extends Object>(
  obj: T, 
  duration: number, 
  from: Partial<T>,
  to: Partial<T>,
  ease: (rate: number) => number = Ease.linear
)

MineMotion.enable()

启用动画。默认导入时自动启用。

MineMotion.disable()

禁用动画。

Classes

MineMotion

动画类。通过此类控制动画。

Methods

pause()

暂停动画。

resume()

继续动画。

Properties

wait: Promise<void>

动画完成时,该Promise会被resolve。

Constants

Ease

一些常见缓动函数的集合。

你也可以自己编写缓动函数或使用网上的缓动函数,只要它们是符合形如 $f: [0, 1] \rightarrow [0, 1]$ 的函数即可。

linear

线性缓动函数。

easeInOut

平滑缓动函数。

easeIn

平滑缓入函数。

easeOut

平滑缓出函数。

sine

正弦缓动函数。