npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

thanos-image

v0.0.6

Published

Thanos snap effect component built with Lit

Downloads

23

Readme

🌌 Thanos Image Web Component

这是一个实现了灭霸消失效果的 Web Component,可以在任何框架(Vue、React、Angular等)中使用。

功能上只有一个文件,packages/ThanosImage/thanos-image.ts ,使用的是 lit 开发的 web component,没有其他依赖库。单文件 7k 左右,加上 lit 打包进去 28k 左右。 要是想更加精简,可以考虑使用原生 js 开发,这样体积会更小。

Inspiration

⚡️ 安装

npm install thanos-image

📝 属性

| 属性名 | 类型 | 描述 | 默认值 | |--------|--------|----------|--------| | src | string | 图片URL | - |

🎮 事件

| 事件名 | 描述 | 参数 | |-------------|------------------|------| | disappeared | 图片消失动画完成时触发 | - |

🛠 方法

| 方法名 | 描述 | 返回值 | |--------------------------|-------------|--------| | playImageDisappearAnimation | 触发消失动画 | Promise |

🎯 示例

查看完整的示例代码:

🌍 浏览器支持

  • ✅ Chrome
  • ✅ Firefox
  • ✅ Edge
  • ⚠️ Safari(基础功能支持,动画效果简化)

⚠️ 注意事项

  1. 在 Safari 浏览器中,由于滤镜支持的限制,会使用简化的消失效果
  2. 如果需要在动画完成后更新图片,建议使用以下模式:
const thanosImage = document.querySelector('thanos-image');
const playButton = document.querySelector('button');

// 预加载图片函数
function preloadImage(src) {
  return new Promise((resolve, reject) => {
    const img = new Image();
    img.src = src;
    img.onload = resolve;
    img.onerror = reject;
  });
}

// 播放动画并更新图片
playButton.addEventListener('click', () => {
  playButton.disabled = true;
  playButton.textContent = 'Animating...';
  
  thanosImage.playImageDisappearAnimation().then(async () => {
    console.log('Animation finished!');
    // 隐藏原图片
    thanosImage.style.display = 'none';
    // 生成新的图片地址(这里使用随机图片作为示例)
    const newSrc = `https://picsum.photos/id/${Math.floor(Math.random() * 1000) + 1}/300/300`;
    // 预加载新图片
    await preloadImage(newSrc);
    // 更新图片源
    thanosImage.src = newSrc;
    thanosImage.style.display = 'block';
    // 恢复按钮状态
    playButton.disabled = false;
    playButton.textContent = 'Play Animation';
  });
});

📄 许可证

MIT © [Arvin]