Adjusting the Size of a Scroll Area

I have an app (DB Schema diagram) where the various tables can be dragged around to create a diagram. The “size” of the scroll area increases any time an object is dragged beyound the current bounds of the scrollarea. I’m trying to determine how/when (or even if) the size should be reduced if the objects no longer take up the full allotted space

simple bounding box should be able to tell you that
take the minimum of the objects left, the min of their tops, the max of their rights and bottoms
and see if that is smaller than the current size of the allotted space

if so then you could reduce the needed scroll area

or am I missing something ?

The question isn’t “how”… it is WHEN should it be done?

Bounding area is increased anytime an object is dragged out of the current bounds. but there are no events to cause the bounds to shrink to the minimum bounding area.

To do those calculation on every “move” is expensive… to increase the size is not, as it only looks at the current moving object… but to decrease it has to look at all objects each time

Current idea is a menu item “Reset Bounds” to leave the decision and timing to the user

maybe when the project is reloaded ?

i’d agree doing it “live” might be jarring

Why not check on MouseUp after the Drag event? That way it won’t check all the time and you know what object was being dragged at the time so you shouldn’t have to check every object (though there might be some times when you’re shrinking the area so you still might have to find the Max values).