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

hana-img-viewer

v4.0.0

Published

A lightweight and easy-to-use image previewer for Vue 3

Readme

hana-img-viewer

A lightweight Vue 3 image viewer that is simple to drop in.

Features

  • Thumbnail-origin FLIP open and close
  • src-first preview path with optional silent previewSrc enhancement
  • Wheel, double-click, drag, and pinch interactions
  • SSR-safe thumbnail-only server render
  • Extracted CSS output with a standard bundler-friendly entry

Installation

pnpm add hana-img-viewer

Basic usage

<script setup lang="ts">
import { HanaImgViewer } from 'hana-img-viewer'
</script>

<template>
  <HanaImgViewer
    src="/images/post-thumb.jpg"
    alt="Article cover"
  />
</template>

Import style.css in main.ts:

import 'hana-img-viewer/style.css'

src and previewSrc

src is required and always drives:

  • the thumbnail
  • the first visible preview frame
  • the FLIP transition source

If previewSrc is provided, the viewer opens from src immediately and upgrades the visible bitmap in place after previewSrc is ready. There is no explicit loading UI and no second transition.

<HanaImgViewer
  src="/images/post-thumb.jpg"
  preview-src="/images/post-full.jpg"
  alt="Article cover"
/>

API

Props

| Prop | Type | Default | Description | | --- | --- | --- | --- | | src | string | - | Required thumbnail and first-preview source. | | alt | string | '' | Accessible alt text. | | previewSrc | string | - | Optional silent enhancement source. | | open | boolean | - | Controlled open state. | | portalTarget | string \| HTMLElement \| null | 'body' | Overlay mount target. null keeps the open request pending until a custom target exists. | | enableZoom | boolean | true | Enable wheel, double-click, and pinch zoom. | | enableDrag | boolean | true | Enable drag while open. | | minZoom | number | 0.5 | Minimum zoom ratio. | | maxZoom | number | 10 | Maximum zoom ratio. | | closeOnMaskClick | boolean | true | Close when clicking the backdrop. | | enableKeyboard | boolean | true | Allow ESC close when the viewer owns the active body portal. | | containerClass | HTMLAttributes['class'] | - | Thumbnail container class hook. | | containerStyle | StyleValue | - | Thumbnail container style hook. | | thumbnailClass | HTMLAttributes['class'] | - | Thumbnail image class hook. | | thumbnailStyle | StyleValue | - | Thumbnail image style hook. |

Emits

| Event | Payload | Description | | --- | --- | --- | | update:open | boolean | Controlled open-state intent. | | open | - | Fired when the viewer becomes visibly open on the client. | | close | - | Fired when the viewer finishes closing. | | load | Event | Fired when the enhancement source becomes active. | | error | Event | Fired when the enhancement source fails. |

Slots

| Slot | Props | Description | | --- | --- | --- | | thumbnail | { open: () => void } | Custom thumbnail trigger. |

Exposed methods

interface HanaImgViewerExposed {
  open: () => void | Promise<void>
  close: () => void | Promise<void>
  reset: () => void
}

Example:

<script setup lang="ts">
import type { HanaImgViewerExposed } from 'hana-img-viewer'
import { ref } from 'vue'

const viewerRef = ref<HanaImgViewerExposed | null>(null)
</script>

<template>
  <button @click="viewerRef?.open()">
    Open
  </button>
  <HanaImgViewer ref="viewerRef" src="/images/post-thumb.jpg" />
</template>

Controlled mode

<script setup lang="ts">
import { ref } from 'vue'

const isOpen = ref(false)
</script>

<template>
  <button @click="isOpen = true">
    Open preview
  </button>

  <HanaImgViewer
    v-model:open="isOpen"
    src="/images/post-thumb.jpg"
    alt="Controlled preview"
  />
</template>

Custom thumbnail

<HanaImgViewer src="/images/post-full.jpg" alt="Custom trigger preview">
  <template #thumbnail="{ open }">
    <button class="thumb-button" type="button" @click="open">
      Open preview
    </button>
  </template>
</HanaImgViewer>

Custom portal target

Use portalTarget when the preview should stay inside a host layer, such as a dialog.

<script setup lang="ts">
import { ref } from 'vue'

const portalTarget = ref<HTMLElement | null>(null)
</script>

<template>
  <div ref="portalTarget" />

  <HanaImgViewer
    :portal-target="portalTarget"
    src="/images/post-thumb.jpg"
    alt="Dialog scoped preview"
  />
</template>

portalTarget="body" and :portal-target="document.body" both use the default body portal behavior.

When portalTarget is a custom element, the host remains the final ESC authority by default.