Hold to Record (Voice Note) new 按住录音(语音消息) web

标本可交互,可以直接操作。

Anatomy — every part, named解剖 —— 每个部件的名字

  1. 1 Record pill录音按钮 pointer capture

    The button that widens into the recording bar while held.

    按住时变宽成录音条的按钮。

    Prompt fragmentPrompt 片段

    an idle pill that widens into a recording bar while pressed

    待机的胶囊按钮,按住时变宽成录音条

  2. 2 Live waveform实时波形 AnalyserNode

    Bars added from the right as levels arrive, each with a bounce.

    音量到达时从右边加入竖条,每根都带回弹。

    Prompt fragmentPrompt 片段

    bars added from the right every 90ms with a bouncy height

    每 90ms 从右边加入一根带回弹的竖条

  3. 3 Slide to bin左滑删除 drag threshold

    Dragging left past 80px arms the bin; letting go there deletes the note.

    向左拖过 80px 时垃圾桶就绪,在那里松手即删除。

    Prompt fragmentPrompt 片段

    drag left past 80px to arm a red bin, release to delete

    左拖超过 80px 垃圾桶变红,松手删除

  4. 4 Playback回放 resample + playhead

    On release the recording is squeezed into the bar count and played back.

    松手后把录音压成固定条数并回放。

    Prompt fragmentPrompt 片段

    resample to N bars and light bars left of the playhead

    重采样成 N 根竖条,播放头左边的竖条点亮

  5. 5 Live tuning实时调参 CSS variables

    Sensitivity, bounce, bar count and corner radius change immediately.

    灵敏度、回弹、条数、圆角改了立刻生效。

    Prompt fragmentPrompt 片段

    sensitivity, bounce, bars and corner radius adjustable live

    灵敏度、回弹、条数、圆角可以实时调节

Prompt — paste into your agentPrompt —— 直接粘贴给你的代理

Build a hold-to-record voice note: an idle pill "Hold to record" with a mic icon. On pointerdown (or holding Space/Enter) it widens and starts recording: a blinking red dot, a timer and a waveform of N bars where a new bar is added from the right every 90ms with a bouncy height transition and the oldest removed. Dragging left moves the pill; past 80px a bin icon turns red. Release past the threshold: the pill shrinks into the bin. Release before it: if the hold was shorter than 350ms show "Keep holding"; otherwise resample the recording into N bars and play it back, lighting bars left of the playhead, then return to idle. Expose Sensitivity, Bounce, Bars and Corner as live settings. Use MediaRecorder and an AnalyserNode in production; respect prefers-reduced-motion.

做一个按住录音的语音消息:待机时是一个带麦克风图标的胶囊按钮「按住录音」。按下(或按住空格 / 回车)时按钮变宽并开始录音:闪烁的红点、计时和 N 根竖条组成的波形,每 90ms 从右边加一根新竖条、高度带回弹过渡,同时删掉最旧的一根。向左拖动时按钮跟着移动,超过 80px 时垃圾桶图标变红。在阈值外松手:按钮缩进垃圾桶。阈值内松手:按住不到 350ms 就提示「再按久一点」;否则把录音重采样成 N 根竖条并回放,播放头左边的竖条点亮,结束后回到待机。把灵敏度、回弹、条数、圆角做成可实时调节的参数。正式产品用 MediaRecorder 和 AnalyserNode;遵守 prefers-reduced-motion。

Debug prompt — when it misbehaves调试 Prompt —— 当它不听话时

Debug my hold-to-record button. Check that pointer capture keeps the gesture alive when the finger leaves the pill; the context menu and text selection are suppressed during a long press; very short taps do not create empty recordings; the bin threshold is measured from the press point; releasing past the threshold never plays the audio; the sampling interval and microphone stream are stopped on every exit path (release, bin, cancel, leaving the page); keyboard users can record with Space or Enter and cancel with Escape; and new bars animate without making the whole row reflow. The symptom:

调试我的按住录音按钮。检查:手指移出按钮时,指针捕获是否让手势继续有效;长按时是否屏蔽了右键菜单和文字选择;很短的点击是否会产生空录音;删除阈值是否从按下的位置开始算;在阈值外松手是否一定不会播放;每一种结束方式(松手、删除、取消、离开页面)是否都停止了采样定时器和麦克风;键盘用户能否用空格或回车录音、用 Esc 取消;新竖条的动画是否没有引起整行重排。症状是:

In code代码里叫什么

Framework框架Symbol符号Note说明
Web pointerdown / pointerup + setPointerCapture hold, slide and release are one pointer gesture按住、滑动、松手是同一个指针手势
Web Audio AnalyserNode.getByteTimeDomainData() read the live level from the microphone for the bars从麦克风读取实时音量来画竖条
Web MediaRecorder record the actual audio while the waveform is drawn画波形的同时录下真实音频
CSS transition-timing-function: cubic-bezier(.3, 1.5, .55, 1) an easing above 1 gives new bars their bounce贝塞尔曲线控制点超过 1 时,新竖条就有回弹

See also相关词条

我的参考集

组合知名网站、UI 元素、视觉风格和平面设计案例,导出给 AI。

你的下一份设计,从这里开始。

在任意案例旁点击「加入参考」,就能把品牌、组件、风格和平面设计案例组合成一份 AI 设计说明。

搜索参考库Search the library

输入关键词,搜索所有参考。