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

3d-rotater-y

v1.0.2

Published

Resolve like 3D badge rotation controls.

Downloads

7

Readme

针对 3D 徽章的预览提供简单的控制能力:通过手指或鼠标控制徽章旋转角度、松手后自动保持水平位置。

Install

$ npm i 3d-rotater-y --save

3d-rotater-y

Features

  • 🚀 动画更新基于requestAnimationFrame
  • 🧭 仅支持 Y 轴方向旋转控制;
  • 🪆 需要附带“根据不同范围内的旋转角度,能够自动过渡到水平位置”的惯性/重力感旋转效果;(从平面视角来看,需要达到[0,90),松手后回到 0 弧度位置;(90,180],松手后回到 PI 弧度位置的旋转过度效果)
  • 👬 同时支持 PC 和移动端;
  • 从指定角度开始归零的旋转过渡动画;
  • 支持初始化时制定任意展示角度;
  • 点击/双击回到初始角度;

Usage

basic

import rotateCtrl from "3d-rotater-y";

/**
* RotateControl(targetDom, targetRadius);
* targetDom 需要控制的元素
* targetRadius 目标元素的半径(宽度的一半,影响手指或鼠标滑动元素时的敏感度),默认200px

  returns {
    rad:Number, //弧度值
    onTouch:Boolean, //是否正在操作被控目标
}
*/

let targetDom = document.querySelector("#badge_stage");
let rotateCtrl = new RotateControl(targetDom);
let isTouching = false;
// 添加监听事件,目前只有一个`update`事件可供监听,并在回调内更新「徽章badgeMesh.rotation.y」
rotateCtrl.on(
  "update",
  ({ rad, onTouch, positiveRad, speed, startRad, endRad }) => {
    isTouching = onTouch;
    badgeMesh && (badgeMesh.rotation.y = rad);
  }
);

// 开始监听旋转控制返回的数据
rotateCtrl.listen();

Advance

/**
* rotateCtrl.reset(duration, resetRad);
* duration 过渡时间ms,默认500
* resetRad 制定重置的角度,默认0
*/

// 比如想在1000ms里,从PI开始重置到0,可以这么用!
rotateCtrl.reset(0, PI);
rotateCtrl.reset(1000, 0);

Todos

  • 模拟 Apple Watch 徽章松手后的**摆动->停止**的过渡效果
  • 完成freezePage函数:手指/鼠标控制目标元素转动时,禁止页面 scrollY
  • 删除playAmt函数:第一个版本,能够实现小摆动,但是停住的时机不够精准;