davidfig / pixi-viewport

A highly configurable viewport/2D camera designed to work with pixi.js
https://davidfig.github.io/pixi-viewport/
MIT License
1.04k stars 174 forks source link

Clarification needed: ensureVisible #163

Open ghost opened 4 years ago

ghost commented 4 years ago

https://github.com/davidfig/pixi-viewport/blob/830e0de7f4f64f49ff61dac868040a8046a41775/src/viewport.js#L926

How is this function intended to be used? The view doesn't change after calling it. Is there another manual render call needed?

davidfig commented 4 years ago

Similar issue to your other problem. ensureVisible works properly in my tests. How did you initialize the viewport?

jasonsturges commented 4 years ago

@davidfig Also confused by this function - it appears to position, but not scale to width and height.

davidfig commented 4 years ago

I just released 4.7.0 that includes an option to change the scale: ensureVisible(x, y, width, height, resizeToFit: boolean). To use it, just call add a true as the last parameter: ensureVisible(x, y, width, height, true) and it'll internally call viewport.fit(width, height) to resize the viewport as needed.