Change document size dynamically

Question: How to get the diagram to know the hosting div has changed size so as to get it to re-draw the part of the diagram that was not previously visible. Looking for a div resize event but ideally something built in to simply call.

Self-Answer: I searched the docs but could not seem to hit on the solution. Then as I was typing my question the new forum tool spat out a bunch of cases referring to diagram.requestUpdate() and links to the resizing sample http://gojs.net/latest/intro/resizing.html - the answer you seek is in the second set of code on that page.

Trying to find how I had missed that I went back to the diagram API page but found it to be absent. I then ran a Google site search site:http://gojs.net/latest requestUpdate which confirmed that this most useful of methods is not documented except in a sample.

Yes, that is intentionally not documented, in order to reduce the likelihood that someone will call it unnecessarily. In our other diagramming libraries, such methods are documented, but all too often programmers will call them in a hope that that will fix their problems. When in fact it doesn’t help but to slow down their application. Eventually they figure out what the real problem was but they leave the “update” call in place because it does not appear to cause any harm.

Unfortunately there is no way for any JavaScript code to know about changes in the size of a DIV element without polling. We did not want to have any polling being used by the GoJS library. So this method is useful for some apps, but it should only be used for that specific purpose.

Anyway I hope I have convinced you that it is not the “most useful of methods”, but only useful in this one circumstance.

Explanation accepted - I guess in your description of what some developers might do you must have seen some of my code ;-) I agree that overuse of the method would hurt performance.

Having added it in to my case it works fine, though I might add a de-bounce function even there.

Debouncing is not necessary for that method – it already is.

Cool - I won’t then.