← 开源

An <img> drop-in WebComponent that brings any photo to life with depth and parallax effects, right on the device.

TypeScript
增长势头
+3724 小时新增 Star+4.3%
905
Star
38
Fork
4
贡献者
创建于 2026-11-30 · 更新于 2026-12-05 · 今日第 402 名
主要开发者
antfucheezonedrichar
README

img-auto-parallax

An <img> drop-in WebComponent that brings any photo to life with depth and parallax effects, right on the device.

🌈 Playground & Documentation →

pnpm add img-auto-parallax
// register WebComponent <img-auto-parallax>
import 'img-auto-parallax/define'
<!-- use <img-auto-parallax> to replace a plain <img> -->
<img-auto-parallax src="/photo.jpg" alt="A mountain lake"></img-auto-parallax>

Powered by vgpu by Vercel.

Requirements

  • HTTPS. WebGPU and device motion events require a secure context. Serve the page over https://, or use localhost during development. Over plain http://, every element renders as a normal <img>.
  • WebGL fallback. Live depth estimation requires WebGPU. On devices without a WebGPU adapter, provide a precompiled depth map with src-depth and the default image layer renders with WebGL. Depth of field and separate foreground/background layers require WebGPU.
  • Gyro permission. iOS Safari requires a user gesture before sharing device motion. Tapping an image prompts automatically. To prompt from your own UI, call getGyroPermission() and requestGyroPermission() inside a click handler. With trigger="auto", touch devices fall back to scroll position until valid tilt readings arrive (respecting reduced motion).

Development

pnpm install
pnpm dev        # docs + playground, using the library source
pnpm run ci     # lint, typecheck, knip, build, test

Sponsors

License

MIT.

The bundled model is licensed under Apache-2.0. See models/NOTICE.md.

排名相邻

AI Rank iPhone 版

随时追踪 AI 模型榜单

在 App Store 下载