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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@wangyaoshen/locus-interaction

v0.1.29

Published

Interactive layer for Locus - drag points, sliders, and interactive components

Downloads

1,010

Readme

@locus/interaction

Locus 交互层 - 为动画引擎提供交互能力

安装

npm install @locus/interaction

功能特性

  • 可拖拽组件: 点、线段、贝塞尔曲线等
  • 滑块控件: 数值参数调节
  • 约束系统: 水平、垂直、网格、圆形路径等
  • 手势管理: 拖拽、键盘控制
  • 交互会话: 暂停动画、等待用户操作、验证结果
  • 反馈系统: 成功/错误动画反馈
  • 播放集成: 与播放系统无缝集成

快速开始

import {
  InteractionManager,
  InteractivePoint,
  horizontal,
} from '@locus/interaction';

// 创建可拖拽点
const point = new InteractivePoint({
  position: [100, 100],
  constrain: horizontal(100), // 只能水平移动
  onMove: pos => console.log('位置:', pos),
});

// 创建交互管理器
const manager = new InteractionManager({
  canvas: document.querySelector('canvas'),
});

// 注册组件
manager.registerComponent(point);

// 开始交互会话
manager.startSession({
  id: 'demo',
  components: [point],
  validation: {
    type: 'position',
    target: [200, 100],
    tolerance: 10,
  },
  onSuccess: () => manager.showSuccess('正确!'),
  onFail: () => manager.showError('再试一次'),
});

模块结构

@locus/interaction
├── math/         # 向量、矩阵运算
├── constraints/  # 约束系统
├── gestures/     # 手势管理
├── controls/     # 会话、验证、反馈
├── context/      # 上下文管理
├── components/   # 交互组件
└── integration/  # 播放集成

约束系统

import {
  horizontal, // 水平约束
  vertical, // 垂直约束
  grid, // 网格吸附
  circular, // 圆形路径
  line, // 直线路径
  bounds, // 边界限制
  compose, // 约束组合
} from '@locus/interaction';

// 组合约束
const constraint = compose(
  grid({size: 10}),
  bounds({xMin: 0, xMax: 500, yMin: 0, yMax: 300}),
);

验证系统

import {Validators} from '@locus/interaction';

// 位置验证
const posValidator = Validators.position([100, 100], 10);

// 数值验证
const valValidator = Validators.value(50, 1);

// 组合验证
const combined = Validators.all(
  Validators.range(0, 100),
  Validators.custom(n => n % 2 === 0),
);

播放集成

import {PlaybackIntegration} from '@locus/interaction';

const integration = new PlaybackIntegration({
  controller: myPlaybackController,
  triggers: [
    {
      frame: 100,
      session: {
        id: 'quiz-1',
        components: [point],
        validation: {type: 'position', target: [200, 200], tolerance: 10},
        autoContinue: true,
      },
    },
  ],
});

API 文档

详细 API 文档请参阅 src/API.ts

版本

当前版本: 0.3.0

License

MIT