Events
Panzoom exposes custom events that can be hooked on to. To set event listeners, use the on
option when initializing Panzoom, or you can use the on()
API method.
The first argument each listener receives is a reference to the current Panzoom instance. Use it to retrieve references to content, container, check their dimensions and get many other useful information.
js
const container = document.getElementById("myPanzoom");
const options = {
click: "toggleCover",
on: {
afterLoad: (instance) => {
console.log("Content has loaded successfully!");
console.log("This is a reference to a content DOM element:");
console.log(instance.content);
},
},
};
new Panzoom(container, options);
Available Events
Name | Description |
---|---|
* | Any event |
init | Initialization has started, plugins have been added |
beforeLoad | Content is loading |
afterLoad | Content has loaded successfully |
error | Content did not load successfully |
ready | Panzoom has successfully launched |
click | Single click event has been detected |
dblClick | Double click event has been detected |
wheel | Wheel event has been detected |
refresh | Container and content dimensions have been updated |
touchStart | Pointer down event has been detected |
touchMove | Pointer move event has been detected |
touchEnd | Pointer up/cancel event has been detected |
decel | Deceleration animation has started |
mouseMove | Mouse move event has been detected |
startAnimation | Animation has started |
endAnimation | Animation has ended |
beforeTransform | The "transform" CSS property of the content will be updated. |
afterTransform | The "transform" CSS property of the content has been updated |
enterFS | Enter full-screen mode |
exitFS | Exit full-screen mode |
destroy | Instance is detroyed |