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

@wavma/enhance

v1.1.5

Published

![Image of Enhance](enhance.png)

Downloads

5

Readme

Image of Enhance

enhance

enhance.js is a library to provide zooming and panning features to any dom element. Influenced by vectors tools like Figma, Sketch, and Autocad, enhance works well with a trackpad (pinch-to-zoom) or a mouse (scrollwheel).

The name "enhance" comes from the canonical Blade Runner scene.

Getting started

npm i @wavma/enhance

yarn add @wavma/enhance

import Enhance from "wavma-enhance";

// enhance needs a parent element to scale within
const parent = document.querySelector(".parent");

// the element is the actual dom object you want to zoom or pan
const element = document.querySelector(".element");

const enhance = Enhance(parent, { element });

Options

Enhance(parent, {
  element: element, // DOM element to focus on
  scale: "contain", // "contain", "cover", or 0.5, 1, 2.5 (float)
  max: 50, // Maximum zoom scale
  min: 0.1, // Minimum zoom scale
  position: "50 50", // "0 0", "100 100"
  offsetX: 0, // default X offset on load and reset
  offsetY: 0, // default Y offset on load and reset
  keyboard: true, // enable keyboard shortcuts
  trackpad: true, // enable trackpad pinch-to-zoom and pan
  pan: false, // enable panning by holding down spacebar and dragging on canvas
  window: false, // enable zoom window selection
});

Methods

enhance.element

Use this method to allow users to upload new images (often svg) or click on different dom elements to reset the zoom.

// Retrieves the current element
const element = enhance.element();

// Sets a new element and by default resets the zoom
// Pass a second argument "false" to keep current zoom
enhance.element(newElement);

enhance.scale

Use this method to create an input for users to manual type in their scale (often easier to think in percentage 0-100%) or a dropdown (ala Google Docs, Photoshop, etc).

// Retrieves the current scale
const scale = enhance.scale();

// Sets a new scale
enhance.scale(1);

enhance.disable

Use this method to

// Removes all the event listeners
enhance.disable();

// Restarts the event listeners
enhance.enable();