We are trying to have our diagram resize when the browser window resizes. We never want the user to be able to zoom further out than the natural size of the diagram in it’s window. Additionally when the resize occurs we want the diagram to re-zoom to it’s new rect. (This is why we reset the minScaleForDiagram property in the code below)
To accomplish this we created a method to be called when the window is resized:
pfdRenderer.refresh = function() {
this.diagram.commandHandler.minScaleForDiagram = this.diagram.scale;
this.diagram.requestUpdate();
this.diagram.zoomToRect(this.diagram.documentBounds)
};
We then attach a function to call this method when the window is resized:
$(window).resize(function() {
pfdRenderer.refresh(); // Have to do it twice for some reason
pfdRenderer.refresh();
});
I have two questions:
1.) Notice that we have to call the refresh() method twice for this to work for some reason. Obviously we must be doing something wrong, is there a timing issue or something?
2.) Is this a decent pattern to use to do what we need to do or is there a more elegant way?
Thanks for any ideas,