Knobs
HTML and javascript knobs. Goal is to replicate the behavior of the knobs in Apple's GarageBand for iOS.
Install / Use
/learn @jherrm/KnobsREADME
Knob.js
Javascript Library for Multitouch Virtual Knobs
Knob.js makes it easy to include multitouch virtual knobs in your web app.
For demos and the story behind Knob.js, check out 🎛 How Apple Designs a Virtual Knob
Knob.js does the heavy lifting for things like:
- Minimum/maximum angle & value constraints.
- Figuring out the position and angle of the indicator dot.
- Doing the math for displaying custom rendered knobs using image sprites.
Knob.js is a purely logical component - rather than drawing or moving things around, it only crunches the numbers and gives back positions and angles. This means that you can render your virtual knobs using CSS, <canvas>, <svg>, or however you like.
Gesture support
Knob.js recognizes spinning and sliding gestures. Spin the knob and it follows your finger. Start sliding up/down or left/right and it locks into the direction and acts like a slider. Mouse interaction including scrolling is also supported.
<img src="https://raw.githubusercontent.com/jherrm/knobs/main/demo/asset/gestures_diagram.svg" />Usage & Demos
The easiest way to get started is to check out the various demos here
- <a href="https://jherrm.github.io/knobs/css.html">CSS Knobs</a>
- <a href="https://jherrm.github.io/knobs/canvas.html">Canvas Knobs</a>
- <a href="https://jherrm.github.io/knobs/svg.html">SVG Knobs</a>
- <a href="https://jherrm.github.io/knobs/sprites.html">Sprite Knobs</a>
More demos in the post 🎛 How Apple Designs a Virtual Knob
Acknowledgements
Knob.js wouldn't be here without Apple's Garageband for iOS. The designers/developers really put a lot of thought into the way a virtual knob should work. Thanks.
The layout of the javascript was heavily influenced by <a href="http://github.com/zynga/scroller">Zynga's Scroller</a>.
Related Skills
node-connect
346.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
107.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
346.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
346.8kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
