Zoom and Pan

zooming and panning is one of the popular interactions, helps focus on the region of interest. I2Djs provides an intuitive way to define the zoom behavior on SVG, Canvas, and webGL layers. I2Djs support multiple interactions as specified below:

Panning: Click and drag, Touch.

Zoom: On the spin wheel, Pinch(2 pointer event), vertical scroll.

API

let zoomInstance = i2d.behaviour.zoom()

zoomStart: Triggered on zoom start.

zoomInstance.zoomStart(function(event){

})

zoom: Triggered continuously on zoom. It will be triggered after zoomStart till zoomEnd.

zoomInstance.zoom(function(event){

})

zoomEnd: Triggered once on zoom ends.

zoomInstance.zoomEnd(function(event){

})

Zoom configuration:

zoomInstance.scaleExtent([minScale, MaxScale]);

zoomInstance.panExtent([topLeft[x, y], bottomRight[x, y]]);

zoomInstance.zoomTarget(point[x, y]);

zoomInstance.zoomFactor(value);

zoomInstance.duration();

Methods inherited by context node:

node.zoomTo(zoomScale, point);

node.zoomBy(zoomScale, point);

node.panTo(point)

Usage:

let zoomInstance = i2d.behaviour.zoom()
zoomInstance.zoomStart(function (event) {
    node.setAttr('transform', event.transform);
});
zoomInstance.zoom(function (event) {
    node.setAttr('transform', event.transform);
});
zoomInstance.zoomEnd(function (event) {
    node.setAttr('transform', event.transform);
});

node.on('zoom', zoomInstance);

//Inherited methods:
node.zoomTo(zoomScale, point);
node.zoomBy(zoomScale, point);
node.panTo(point);

Last updated