Wipe reveal
擦除揭示
Uncover an image by moving its clipping boundary.
Also searched as: 图片像揭幕一样从一边展开, 图片从左往右擦出来, 图片从左往右揭开, 图片一点点露出来, 遮罩揭示
- Placement
- Image, Hero heading
- Mood
- Dramatic, Refined
- Trigger
- 进入屏幕
- Site types
- 作品集, 博物馆和展览, 品牌官网
How it works & accessibility
Animate the clip-path boundary to uncover the image while keeping the surrounding layout unchanged.
Best for: Image, Hero heading (进入屏幕).
Reduced motion: 不播放动画,图片直接完整显示
Mobile & touch: 和桌面一样;很大的图在低端手机上可能掉帧,可以把时长调短一点
Key parameters
| Parameter | Key | Default | Range | Notes |
|---|---|---|---|---|
| 时长 | duration | 900ms | — | — |
| 缓动 | easing | cubic-bezier(0.76, 0, 0.24, 1) | — | — |
Ready-to-paste AI prompt
Add “Wipe reveal” to the image in my project: Animate the clip-path boundary to uncover the image while keeping the surrounding layout unchanged.
Parameters: duration: 900ms, easing: cubic-bezier(0.76, 0, 0.24, 1).
Preserve existing content and layout. Respect prefers-reduced-motion by showing the final state. Content must remain visible if JavaScript fails or is disabled.
Reference: https://donglang.linter.top/effects/clip-reveal.md (canonical specification and reference code).Dependency-free reference code
CSS
/* 擦除揭示不需要额外的样式:元素默认就是完整的,动画开始前那一瞬才由脚本裁掉 */JavaScript
// 擦除揭示(Wipe reveal)· 原生 JS,不依赖任何库。
// 改写自 Animation Handbook 的 clip-path-reveal(MIT License,Copyright (c) 2026 Matin Monshizadeh):做法来自它,默认值调过。
// el 先被从右边裁掉,再从左往右露出来(clip-path: inset()),元素本身不动。返回一个清理函数:调用它会停掉动画,元素完整显示。
// 元素自己已经有 clip-path(比如裁成圆角、斜边)时,动画期间会被盖掉、播完才恢复:在它外面包一层,把揭示加在外层上。
// 开启"减少动态"时不播放,直接完整显示;动画用 fill: 'backwards',脚本出错或没执行时元素照样完整可见。
// ignoreReducedMotion 只给"用户主动点播放"的演示用,网站自己的元素不要打开它。
export function clipReveal(el, {
duration = 900,
easing = 'cubic-bezier(0.76, 0, 0.24, 1)',
ignoreReducedMotion = false,
} = {}) {
if (!ignoreReducedMotion && matchMedia('(prefers-reduced-motion: reduce)').matches) return () => {};
const animation = el.animate(
[{ clipPath: 'inset(0 100% 0 0)' }, { clipPath: 'inset(0 0% 0 0)' }],
{ duration, easing, fill: 'backwards' },
);
return () => animation.cancel();
}
// 元素进入屏幕时播放一次。
// 离屏幕底边还有 40px 时就开始(碰到一点就算):动画的第一帧是藏起来的,等露出一截再开始,会先完整露一下、再消失、再进场;
// 按露出的比例算,比屏幕还高的元素可能永远够不到比例、一直不播。root: document 让提前量按元素所在页面自己的视口算,放在 iframe 里也管用
export function clipRevealOnEnter(el, options) {
const io = new IntersectionObserver(([entry]) => {
if (!entry.isIntersecting) return;
io.disconnect();
clipReveal(el, options);
}, { root: document, threshold: 0, rootMargin: '0px 0px 40px 0px' });
io.observe(el);
return () => io.disconnect();
}HTML
<!-- 擦除揭示:给要揭开的图片(或任何元素)调用一次 -->
<img class="artwork" id="artwork" src="artwork.jpg" alt="作品图">
<script type="module">
import { clipRevealOnEnter } from './clip-reveal.js';
clipRevealOnEnter(document.getElementById('artwork'));
</script>