is it possible to set x and y from canvas.zoom
i’m using react and import from bpmn-js/lib/Modeler
what i’m trying is to change function canvas.zoom(scale,x,y) where x,y is x,y from _cachedViewbox. But i can’t find function canvas.zoom.
the scale work perfectly
and one more thing is it possible to check if user doing something so i can autosave if something change
sry for my english
Thanks
x
and y
in the second argument of zoom
refer to screen coordinates. They do not refer to diagram coordinates. The documentation is not clear about this. We’ll look into this and maybe add the possibility to specify diagram coordinates when using zoom
.
In the meantime you can use this function from diagram-js-minimap that solves the same problem:
function setViewboxCenteredAroundPoint(point, canvas) {
// get cached viewbox to preserve zoom
var cachedViewbox = canvas.viewbox(),
cachedViewboxWidth = cachedViewbox.width,
cachedViewboxHeight = cachedViewbox.height;
canvas.viewbox({
x: point.x - cachedViewboxWidth / 2,
y: point.y - cachedViewboxHeight / 2,
width: cachedViewboxWidth,
height: cachedViewboxHeight
});
}
Please open a separate thread for this question.
1 Like