Typing Loop 打字循环
The same string typed and deleted forever, with a different speed for each direction. 同一句话反复打出来又删掉,两个方向的速度不一样。
Runs live on this page. Move the pointer, click, or drag — whichever the effect listens for. 就在本页实时运行。移动鼠标、点击或拖拽——看它响应哪一种。
How it works原理拆解
A single del flag drives a two-state machine: growing until i exceeds the length, then shrinking until i hits zero. Deletion runs at 80ms per character versus 140ms for typing — that asymmetry is why it feels deliberate rather than mechanical. 一个 del 标志驱动两状态机:长到超过长度就切删除,删到 0 再切回来。删除是每字 80ms,打字是 140ms——正是这个不对称让它显得有意为之,而不是机械循环。
What to change可以改的地方
- 1Make the delete delay larger than the type delay for a reluctant, sad rhythm.
- 2Add a 1s pause at full length before deleting.
- 1删除延迟调得比打字还慢,会读出一种犹豫的情绪。
- 2打满之后停 1 秒再删,节奏会从容很多。
Source code源码
Self-contained — paste it into any HTML file and it runs. No libraries. 完全独立——粘进任意 HTML 文件就能跑,不需要任何库。