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

yu-ani

v1.0.7

Published

js动画

Downloads

3

Readme

yu-ani

js动画函数

安装

npm install yu-ani --save

引入

import { ani, Yu, getOffset, inertia } from 'yu-ani';

ani(options) 数字补间动画

let options = {
	duration: 300,  //默认300毫秒
	initial: { x:0,y:0,arr:[0,0] }, //动画初始值
	target: { x:100,y:50,arr:[150,80] },  //动画目标值
	update(current){    //每一帧动画的回调函数
		//current 动画当前值
	},
	complete(current){    //动画停止后的回调函数
		//current 动画当前值
	}
}
let status = ani(options);
/* 
	status.pause()    	//动画暂停
	status.regain()   	//动画暂停后恢复
	status.reset()  		//动画重置到最初
	status.reset(true)	//动画重新开始
	status.stop()				//动画立即停止。
	status.stop(true) 	//动画立即完成
*/

Yu——数字补间动画的链式调用方式

let status = new Yu({ x:0,y:0 })  //动画初始值
		.to({ x:100,y:50 })  					//动画目标值
		.duration(500)								//动画持续时间500毫秒
		.update(current=>{})						//每一帧动画的回调函数,current是动画当前值
		.complete(current=>{})				//动画停止后的回调函数
		.start();											//启动动画

/* 
	status.pause()    	//动画暂停
	status.regain()   	//动画暂停后恢复
	status.reset()  		//动画重置到最初
	status.reset(true)	//动画重新开始
	status.stop()				//动画立即停止。
	status.stop(true) 	//动画立即完成
*/

getOffset(options) 元素的pc端点击事件,和移动端的触屏事件

let options = {
	element: document.querySelector('div'),
	down(offset){},   //鼠标按下事件
	up(offset){},			//鼠标松开事件
	start(offset){},	//手指触屏事件
	end(offset){},		//手指离屏事件
	move(offset){}		//鼠标移动事件,手指屏幕移动事件
}
/* 
	offset.x		//鼠标按下时的x轴坐标,手指触屏时的x轴坐标
	offset.y		//鼠标按下时的y轴坐标,手指触屏时的y轴坐标
	offset.mx		//鼠标移动时的x轴坐标,手指屏幕移动时的x轴坐标
	offset.my		//鼠标移动时的y轴坐标,手指屏幕移动时的y轴坐标
	offset.speedX		//鼠标x轴的移动速度,手指x轴的移动速度
	offset.speedY		//鼠标y轴的移动速度,手指y轴的移动速度
	offset.ex		//鼠标松开时的x轴坐标,手指离开屏幕时的x轴坐标
	offset.ey		//鼠标松开时的y轴坐标,手指离开屏幕时的y轴坐标
*/
}

inertia(speeds, update, complete, rub) 惯性动画

let speeds = { x:2, y:1 }  		//每一帧的速度值
function update (current) {		//每一帧的回调函数
	//current   		计算摩擦比率后的当前速度值
}
function complete(current){}	//动画完成的回调函数
let rub = 0.95								//每一帧动画的摩擦比率,默认0.95

inertia(speeds, update, complete, rub)