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

react-zoomer

v0.1.2

Published

This package provides a React component that takes an image URL as a prop and loads it into a canvas. The user can pan and zoom via mouse wheel on desktop or pinch-zoom on a mobile device.

Downloads

7

Readme

React Zoomer

This package provides a React component that takes an image URL as a prop and loads it into a canvas. The user can pan and zoom via mouse wheel on desktop or pinch-zoom on a mobile device.

Live Demo

A working demo can be found at https://tyler.digital/demo/react-zoomer

Installation

npm i --save react-zoomer 

Usage

First, you must change the "viewport" meta tag in your projects index.html file to the following:

<meta 
    name='viewport' 
    content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' 
/>

The zoomable component has only a few settings and props and is easily added into any React application:

import React from 'react';
import ReactDOM from 'react-dom';
import Zoomer from 'react-zoomer';
import './index.css';

let settings = {
    background_color: "#eee",
    width: "100%",
    height: "500px",
    minZoom: 0.5 // set minimum zoom to  50% of original size
 };

ReactDOM.render(
    (
        <div className="zoomer-demo">
            <Zoomer
              image="https://d3bx4ud3idzsqf.cloudfront.net/public/production/7386/68915_high_res_1536869974.jpg"
              settings={settings} 
            />
        </div>
    ), document.getElementById("root")
);

Supported props

image: the URL of the image
settings: an object containing any of the following keys:
  - background_color: sets the background color of the canvas
  - width: sets the width of the canvas, in % or px
  - height: sets the height of the canvas, in % or px
  - minZoom: a number between 0.1 and 1, sets the minimum zoom.  This is the furthest a user will be able to zoom out of the image. 
  - maxZoom: a number greater than 1, the maximum a user will be able to zoom into the image.

Known issues

  1. In iOS Safari 10+, when the total page height/width is greater than the canvas height/width, dragging on the canvas can cause the page to scroll.

More information

The code for this package can be found at https://github.com/tkivari/react-zoomer