nexu-io/open-design / skills/oil-motion
oil-motion
Verified处理视频和序列帧,编译滚动、指针、拖动与状态驱动的网页动效;内含本地媒体处理脚本和运行时。新素材生成使用宿主工具。
assets/step-gesture.ts
View on GitHubexport type StepDirection = -1 | 1;
export type StepGestureOptions = {
threshold?: number;
idleMilliseconds?: number;
onStep: (direction: StepDirection) => void;
};
export type StepGestureAdapter = {
feed(delta: number): void;
setProgrammaticNavigation(active: boolean): void;
reset(): void;
destroy(): void;
};
export function createStepGestureAdapter(
options: StepGestureOptions,
): StepGestureAdapter {
const threshold = Math.max(1, options.threshold ?? 40);
const idleMilliseconds = Math.max(16, options.idleMilliseconds ?? 140);
let accumulated = 0;
let lockedDirection: StepDirection | 0 = 0;
let programmaticNavigation = false;
let releaseTimer = 0;
let destroyed = false;
const clearRelease = () => {
if (releaseTimer) window.clearTimeout(releaseTimer);
releaseTimer = 0;
};
const reset = () => {
clearRelease();
accumulated = 0;
lockedDirection = 0;
};
const scheduleRelease = () => {
clearRelease();
releaseTimer = window.setTimeout(reset, idleMilliseconds);
};
return {
feed(delta: number) {
if (
destroyed ||
programmaticNavigation ||
!Number.isFinite(delta) ||
delta === 0
) return;
const direction: StepDirection = delta < 0 ? -1 : 1;
if (lockedDirection === direction) {
scheduleRelease();
return;
}
if (lockedDirection === -direction) {
accumulated = 0;
lockedDirection = 0;
}
if (accumulated && Math.sign(accumulated) !== direction) accumulated = 0;
accumulated += delta;
scheduleRelease();
if (Math.abs(accumulated) < threshold) return;
accumulated = 0;
lockedDirection = direction;
options.onStep(direction);
},
setProgrammaticNavigation(active: boolean) {
programmaticNavigation = active;
if (active) reset();
},
reset,
destroy() {
destroyed = true;
reset();
},
};
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |