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

my-flip-animation

v1.0.0

Published

an easy lib for FLIP animation

Downloads

2

Readme

my-flip-animation

这是对FLIP动画的一个简单实现。

旨在用最简单的方式告诉读者FLIP是如何实现的。

介绍FLIP

FLIP,将一些开销高昂的动画,如针对 width,height,left 或 top 的动画,映射为 transform 动画。

所以 FLIP 来源于 First,Last,Invert,Play。

分解一下:

  • First:元素的初始状态。
  • Last:元素的最终状态。
  • Invert:先计算出从初始状态到最终状态元素发生的改变,比如宽度、高度、透明度等,然后在元素上应用一个 transform 或 opacity 使这些改变反转。如果一个元素由初始状态到最终状态是向下移动了 90px,那就需要对元素应用 transform: translate(0, -90px),这样就使元素看起来还在初始位置。
  • Play:移除元素上的 transform 并设置 transform 相关的动画。

API

仅暴露一个接口:

function flip(element, handler, duration = 0.3, timingFn = 'ease')
  1. element,表示需要做FLIP处理的元素
  2. handler,表示一个函数,这个函数可以包含所有让element位置变化的操作,应该使用同步代码。handler的第一个参数是element,建议写成箭头函数:(element) => {/** your code **/}
  3. duration,表示执行FLIP动画的持续时长,默认为0.3秒
  4. timingFn,表示FLIP动画的加速度曲线,默认为'ease',还有linear、step-start等可以选择

演示地址

CodePen演示地址