Skip to content

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 this to retrieve references to the content, container, check their dimensions, and get a lot of other useful information.

js
const container = document.getElementById("myPanzoom");
const options = {
  clickAction: "toggleCover",
  on: {
    loaded: (instance) => {
      console.log("Content has loaded successfully!");

      console.log("This is a reference to the container DOM element:");
      console.log(instance.getContainer());
    },
  },
};

Panzoom(container, options).init();

Available Events

NameDescription
*Any event
actionAction is being executed (for example, "zoomIn")
animationEndAnimation has ended
animationStartAnimation has started
clickSingle click event detected
dblClickDouble click event detected
destroyInstance is destroyed
errorContent did not load successfully
initInitialization has started
initLayoutLayout is initialized
initPluginsPlugins are initialized
loadedContent successfully loaded
loadingContent is loading
pinchPinch-zoom gesture detected
readyPanzoom has successfully launched
refreshContainer and content dimensions are updated
renderViewport CSS properties are updated
touchEndPointer up/cancel event detected
touchStartPointer down event detected
wheelWheel event detected