scrollMargin only adds margin vertically

diagram.scrollMargin only adds margin to vertical scroll, not with horizontal scroll. Is this normal behavior?

I’ve tried both scrollMargin: 100 and scrollMargin: new go.Margin(100, 100, 100, 100)

I’m seeing some weird behavior when using scrollbars, but it looks OK when panning. We’ll investigate.

How are you scrolling?

You are right, it works fine when panning.

I’m resizing the browser window until scrollbars appear, then scrolling by clicking/dragging the scrollbar. I also noticed the weird behavior where it doesn’t scroll on the first click/drag but works after that. This happens only when scrolling through the scroll bar.

I do think the scrollbar issue is a bug.

For working only in one direction: It seems that we created scrollMargin so that it only works if the documentBounds is very close in size or larger than the viewportBounds.

The document bounds being the green rectangle here, and the viewport bounds being the canvas itself:

This can be scrolled “extra” (the scrollMargin amount) horizontally, but not vertically. I’m not yet sure if we’re doing the right thing there or not.

But the scrollbar issues are very likely a bug in the implementation, so I’ll be looking into that.

Can you try:

[EDIT: obsolete]

And tell me what you think?

I fixed the scrollbar issues. I do think that you should be able to always see the right amount of pixels of “empty space” on all margins of the document bounds, too.

I think it’s fine and it’s exactly how I expected it to behave.

Your recent change fixed the scrollbar issue, thank you!

Though I’ve noticed a quirk with contentAlign: go.Spot.Center where scrollbars from the scrollMargin appear but of course the diagram won’t scroll/pan as it’s always centered. Before the change, scrollbars only appear if the documentBounds is bigger than the viewportBounds. Not sure if this is a bug, though it makes sense that it’s there because of the scroll margins.

That may be a bug, I’ll review.

It is not well-defined what ought to happen when contentAlignment and scrollMargin are set, so the functionality may always be a compromise, but the existence of a scrollbar that appears but is non-functional is a bug, so that’s been fixed too.

With contentAlignment set, scrollMargin won’t work until the document bounds are larger than the viewport bounds, in order to satisfy contentAlignment's need to peg the document bounds to a specific place. If the doc bounds are larger than the viewport, then it works as normal (and contentAlignment has no effect, regardless, when that happens).

That makes sense. Thank you