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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@femessage/img-preview

v1.5.0

Published

[![Build Status](https://travis-ci.com/FEMessage/img-preview.svg?branch=master)](https://travis-ci.com/FEMessage/img-preview) [![NPM Download](https://img.shields.io/npm/dm/@femessage/img-preview.svg)](https://www.npmjs.com/package/@femessage/img-preview)

Downloads

32

Readme

img-preview

Build Status NPM Download NPM Version NPM License PRs Welcome Automated Release Notes by gren

Picture preview component

中文文档

Table of Contents

Feature

  • Implementation like medium
  • Automatically adaptation screen size
  • The small picture is not vague, the big picture does not overflow the screen
  • Support Press ESC Key to off preview

⬆Back to Top

Demo

⬆Back to Top

Install

yarn add @femessage/img-preview

⬆Back to Top

Picture Preview Algorithm

When the original size of the preview picture is relatively large, you need to preview the picture proportionally.

// X-axis ratio = width of the window / width of the image
// Y-axis ratio = height of the window / height of the picture
// Image ratio = x-axis ratio * (picture height > window height ? y-axis ratio: x-axis ratio)

Here's more details of the formula:

  • Step 1, calculation x-axis ratio (The ratio of the browser window width to the original width of the picture) and save it

WechatIMG5.jpeg

  • The second step, considering x-axis ratio below, it is possible that the height of the picture is larger than the height of the window. At this time should use y-axis ratio (The ratio of browser window height to the original height of the picture) as the preview ratio of the picture

WechatIMG61.jpeg

⬆Back to Top

Contributors

Thanks goes to these wonderful people ( Emoji key ):This project follows All-contributors Specification. Contributions of any kind welcome!

⬆Back to Top

License

MIT

⬆ Back to Top