Closed fix777 closed 3 years ago
Ah. Scrollbox assumes your top-left corner is 0, 0. The underlying viewport that scrollbox is based on handles negative values fine, it's just the scrollbox calculations for scrollbars and clamping and such that limit the top-left value. It's possible to tweak the code to allow for arbitrary corners, but I currently don't have plans to do so. I'm happy to take a PR if you're interested.
The easiest way to hack it is to normalize your items. Search through the items and find the smallest x and y. If the smallest value is < 0 then add the negative amount to all items.
A more complicated approach that takes into account rotations and such is to find the bounding box of scrollbox.content (the viewport inside the scrollbox), and then change its position by the negative top-left value in the same way. There'll likely be some tweaking necessary for this to work.
Good luck!
Thanks, David, I will give it a try. Closing for now.
Here is a CodeSandbox. I give 2 Sprites in the CodeSandbox: