Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

d3-zoomable

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3-zoomable

Easy way to apply d3-zoom functionality to DOM elements

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.2K
decreased by-44.88%
Maintainers
1
Weekly downloads
 
Created
Source

d3-zoomable

NPM package Build Size Dependencies

This reusable component provides an easy way to make DOM elements zoomable/pannable using mouse wheel/drag events. It is mostly a convenience wrapper around d3-zoom functionality which hides away some of the complexity and provides easy access to common use cases.

Supports zooming svg (via transform attribute), canvas (via context transform) or even plain html DOM elements (via transform style).

Quick start

import zoomable from 'd3-zoomable';

or

const zoomable = require('d3-zoomable');

or even

<script src="//unpkg.com/d3-zoomable"></script>

then

const myZoom = zoomable();
myZoom(<DOM element to capture mouse events>)
    .svgEl(<SVG element to transform>);

API reference

MethodDescriptionDefault
htmlEl([node or d3-selection])Getter/setter for the HTML DOM element to control using the transform style property.
svgEl([node or d3-selection])Getter/setter for the SVG DOM element to control using the transform attribute.
canvasEl([node or d3-selection])Getter/setter for the Canvas DOM element to control using context transform operations.
enableX([bool])Getter/setter for whether to enable zooming along the X axis.true
enableY([bool])Getter/setter for whether to enable zooming along the Y axis.true
scaleExtent([[number, number]])Getter/setter for the zoom limits to enforce, similar to d3-zoom scaleExtent.[1, ∞]
translateExtent([[[number, number], [number, number]]])Getter/setter for the pan limits to enforce, similar to d3-zoom translateExtent.[[-∞, -∞], [+∞, +∞]]
current()Getter for the current transform settings, in { x, y, k } syntax.
zoomBy(number[, duration])Programmatically adjust the zoom scale by a certain amount. Optionally set a transition duration (in ms) to animate the transformation.
zoomReset([duration])Programmatically reset the zoom to its initial setting ({ x: 0, y: 0, k: 1 }). Optionally set a transition duration (in ms) to animate the transformation.
zoomTo({ x, y, k } [, duration])Programmatically apply a certain zoom setting, defined by the x, y translation, and the k scaling. Optionally set a transition duration (in ms) to animate the transformation.
onChange(fn(newTransform, previousTransform, duration))Callback function invoked whenever the zoom settings change, either by user interaction of programmatically. The callback arguments include the new transform ({ x, y, k } syntax), the previous transform, and the duration of the zoom (in ms) in the case of programmatic requests.

Keywords

FAQs

Package last updated on 14 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc