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";
const parent = document.querySelector(".parent");
const element = document.querySelector(".element");
const enhance = Enhance(parent, { element });
Options
Enhance(parent, {
element: element,
scale: "contain",
max: 50,
min: 0.1,
position: "50 50",
offsetX: 0,
offsetY: 0,
keyboard: true,
trackpad: true,
pan: false,
window: false,
});
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.
const element = enhance.element();
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).
const scale = enhance.scale();
enhance.scale(1);
enhance.disable
Use this method to
enhance.disable();
enhance.enable();