Panzoom: transforms instead of layout, and an IE11 workaround in a 4.x readme
A library for panning and zooming elements using CSS transforms :mag:
At a glance
- What is it?
- timmywil/panzoom is a small TypeScript library that pans and zooms any element with CSS transforms, about 3.7 kilobytes gzipped, published in six loading flavours. Its readme delegates browser support to a query URL, splices an unnumbered section into the middle of its own numbered FAQ, and answers the PDF blurring question by linking to a forum thread.
- Who is it for?
- Panzoom fits a page that needs to make one element bigger and movable, on desktop and on touch, without a framework and without a dependency tree: the whole mechanism is transforms, the whole payload is a few kilobytes, and the load paths cover script tags, module imports, AMD and CommonJS.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 13 days ago.
- What is it written in?
- Mainly TypeScript, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 15, 2026, and from our analysis. They are not legal advice.
Star history
- timmywil/panzoom2,477 ★ · +8
| Repository | 2026-09-30 | 2026-11-15 |
|---|---|---|
| timmywil/panzoom | 2.5k | 2.5k |
8 Stars in the last 46 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
Transforms instead of layout, on anything at all
The mechanism is one decision and the readme states the alternative it rejects. Rather than using absolute positioning, or setting width and height, Panzoom applies CSS transforms, which is what lets the browser use hardware acceleration. That choice is why the element can be anything: an image, a video, an iframe, a canvas, or text. The cost of that choice is equally real and worth holding onto, because a transform moves a rendered surface rather than changing a box, so anything downstream that depends on layout does not see a change. Size is treated as a feature rather than an accident. The readme quotes roughly 3.7 kilobytes gzipped, and that number is not a claim anyone has to take on trust, because the scripts include a step that measures the gzipped size after minification and runs as part of the build. The package also ships its own source directory alongside the built files, so a debugger can step through the actual TypeScript rather than a bundle.
The browser support list is a query URL
Instead of naming browsers, the readme links to a query service with its filters encoded in the address, excluding the no data browser and setting a usage threshold of a quarter of one percent, and it separately excludes the mini browser line. That is a defensible way to keep a support policy current without editing prose, and it has one consequence worth knowing: the support matrix is not readable in the repository. If that service is unavailable, or if you need to know what the policy was on a given date, the answer is not in the readme and would have to be reconstructed from the query. Mobile support is stated in plain terms instead: iOS, Android and Windows Mobile, with touch gestures, pinch gestures for zooming, and pointer events used by default wherever they are supported. The pitch is that the same gesture model covers a phone and a desktop, which is true as long as the browser reports pointer events, and the library's own preference for them is stated rather than assumed.
Six loading routes, and the CDN one pins a version
The install section is generous with options because the library is built as a UMD bundle. Package managers get one line each, and the examples are quoted the way a reader would type them:
$ npm install --save @panzoom/panzoomFrom there the readme covers ES module imports, CommonJS or browserify requires, an anonymous AMD define, a plain script tag, and a CDN script tag whose address ends in the exact version number of the release rather than a floating latest tag. That is a small thing to notice and a good habit in an example, because most documentation links a CDN build without a version and quietly teaches people to ship whatever is current. The manifest matches the breadth, declaring both a CommonJS entry point and a module entry point, a source field pointing at the TypeScript, a type declaration file, and the module type flag, which is how one package can be required by a bundler, imported by a modern tool and dropped into a page by hand. The keyword list is short and honest, six words about panning, zooming and dragging.
An IE11 workaround for SVG transitions survives in a 4.x readme
The SVG section is where the age of the document shows. Panzoom supports panning and zooming SVG elements directly, and then the readme devotes its attention to a browser whose CSS animations and transitions do not work on SVG elements, at least for the transform style, while noting they do work elsewhere. The workaround offered is manual: use the transform setter option and integrate a tweening library for the animation, with a link to a tweening library that happens to be addressed by an old hash-fragment URL. None of this is wrong to keep, and it is genuinely useful if you have to support that browser, but the fact that a 4.x release readme carries it tells you the library's compatibility story is anchored to a much older web than the version number suggests. Everything else in the file, pointer events, ES modules and hardware accelerated transforms, is modern. The inconsistency is the only oddity.
The FAQ is interrupted between its third and fourth items
Structure is the story here, because the readme's numbered list stops and restarts. The first three questions are real questions with real answers: what transform origin is and why the library sets it, since focal point zooming depends on the origin and HTML elements default to the centre while SVG elements default to the top left corner; why an object element swallows the events, with the fix being to disable pointer events on it and wrap it; and why links stop working, with the fix being an exclude class whose default name is printed in the file, or a reference in the exclude option, or stopping event propagation in your own handler. Then an unnumbered section about the asynchronous nature of the library, and after that the list resumes at item four. The async note is worth its own place: setting a zoom and then a pan synchronously usually works, but breaks when the contain option is set, because retrieving proper dimensions requires the scale to have been painted, and the fix is to defer the second call. Item five then answers the question about a canvas rendering a PDF by linking to a forum thread rather than answering it.
Two bundlers, and the minified build keeps a banner on purpose
The build scripts describe a project that is careful about its output. The library itself is bundled with one tool and the demo application with another, which is normal and also means the two halves of the repository can fail independently. The minification step is the interesting one: it compresses and mangles and filters comments through a pattern matching the author's name, which is a deliberate choice to keep a banner in the minified file that a naive minifier would strip, and then it runs the size measurement script. That size script is what makes the readme's kilobyte claim reproducible on every build rather than a number someone measured once. Around it sit the ordinary but well chosen pieces: commit hooks installed on prepare, a conventional release tool, a type check run as part of linting, a browser test runner and a separate plain Node test that runs against the built bundle rather than the source, and generated documentation produced from the TypeScript with the type documentation plugin.
Options are grouped by lifetime, and one is deliberately not global
The option model is tidier than most libraries of this size, and the readme explains it in a way that answers the question you were about to ask. There are three option groups, a miscellaneous group, a pan group and a zoom group, and the full set is what you pass when you create the instance. The global set is identical except that it excludes one option, and that exclusion is the point worth remembering: the force flag can only be passed to an individual pan or zoom call, because it should not be set globally, so you cannot make one call override the rest of the configuration. Everything else in the set can also be passed to a pan or a zoom function, so a one-off override is a normal thing to do. Two more entries show the level of care here. The canvas option treats the element's parent as the surface, binds the pointer handler to the parent so a movement anywhere in that area moves the child, and moves where the cursor style is applied as a side effect. And the signature is indexable, so you can pass arbitrary extra options through to your own handlers.
Editorial conclusion
Panzoom fits a page that needs to make one element bigger and movable, on desktop and on touch, without a framework and without a dependency tree: the whole mechanism is transforms, the whole payload is a few kilobytes, and the load paths cover script tags, module imports, AMD and CommonJS. It does not fit a case where you need layout that reflows, since transforms move pixels rather than boxes, and the readme is clear that the alternative approach it rejects is the one that changes width and height. Before you use it, check four things. Which element you are attaching it to, because object elements swallow events and SVG text needs an attribute added. What the default transform origin will be, since it differs between HTML and SVG and focal point zooming depends on it. Whether any synchronous pair of calls needs deferring, because dimensions require a paint. And what you exclude from the pan handler, since a link inside the element will be swallowed unless you register it.
Frequently asked questions
How do I install and use Panzoom?
Install the package with npm or yarn, or load a UMD build with a script tag, an ES module import, a CommonJS require or an AMD define. Create an instance with the element and an options object, then call the pan and zoom methods, or bind the provided zoom in, zoom out and wheel handlers to your own controls. Panning and pinch are bound automatically unless you disable them.
Why are links inside a Panzoom element not clickable?
Because Panzoom handles the pointer events. Mark the element you want clickable with the exclude class option, whose default is named in the readme, and the library will check for it before handling the event. You can also pass the element to the exclude option or stop event propagation in a click handler on the element itself.
Why does setting a zoom and then a pan at the same time misbehave?
Because Panzoom needs proper dimensions, and the scale has to have been painted before they can be read. This shows up most visibly when the contain option is set. The readme's fix is to defer the second call, for example by running the pan inside a timeout after the zoom.
What is the size of the Panzoom library?
The readme quotes roughly 3.7 kilobytes gzipped, and that figure is produced by a size measurement script that the build runs after minification. The minification step also filters comments through a pattern matching the author's name, so a banner is deliberately kept in the minified file.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/timmywil-panzoom)Star history chart for your README
[](https://hysenlabs.com/projects/timmywil-panzoom)Was this useful?