Closed jasonsturges closed 6 years ago
Content in my viewport is perfectly centered thanks to bounce and fitWorld(); however, clamp is engaged only after the mouse wheel event. What if I want the viewport initialized with clamp constraints on first render?
Try v3.9.0. clampZoom now clamps when it's first called. It also clamps whenever you call fitWidth, fitHeight, fit, zoom, or zoomPercent.
Hopefully that helps you get rid of the extra zoom call.
In the API Documentation, there's no reference to coordinate system for boundaries. Presumably these are world dimensions?
All coordinates in pixi-viewport are world coordinates unless screen is specified. clampZoom uses worldScreenWidth/Height to figure out the zoom.
Minimum zoom is as far as you can zoom out, and maximum zoom is as far as you can zoom in, right? In that example, width and height are 5000, but minWidth is set to 1000 and maxWidth is set to 2000.
Yes, I think that's right. For example, minWidth is the minimum number of world pixels that will fit on the screen.
Awesome - this is great. Thanks for the insights.
Not sure I understand
clampZoom()
- three issues:clampZoom()
be used when the viewport is first setup? Clamp is enabled only after first zoom interaction.If I initialize viewport as:
Content in my viewport is perfectly centered thanks to
bounce
andfitWorld()
; however, clamp is engaged only after the mouse wheel event. What if I want the viewport initialized with clamp constraints on first render?Currently after
fitWorld()
I have to execute a zoom, like: