Need to disable Scroll in diagram enable when reaches bottom

I need to disable Vertical scroll bar in the beginning and need to enable only when text overflows graph.
Please help me with suggestions.

For disable I used “allowVerticalScroll:false,” but how I can get a idea when to enable it.

Thanks

By default, a diagram won’t display a scrollbar if the contents fit within the viewport. The relative sizes of the Diagram.documentBounds and Diagram.viewportBounds control whether scrollbars are displayed. See the intro on coordinate systems in GoJS. Once the contents of the diagram are larger than the viewable area, a scrollbar will appear.

Is this not what you want? If not, could you provide some kind of sketch or mockup detailing what you want for the scrollbar?

thanks for the reply I got a solution by overriding the
“diagram.addDiagramListener(“ViewportBoundsChanged”, function(e)”