davidfig / pixi-viewport

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

Animate ensureVisible #256

Open pspeter3 opened 4 years ago

pspeter3 commented 4 years ago

Is it possible to animate the ensureVisible function?

davidfig commented 4 years ago

There's no built in function, but you can use the code from ensureVisible (https://davidfig.github.io/pixi-viewport/jsdoc/src_viewport.js.html#line1023) to calculate the values you need to plug into the animate function (https://davidfig.github.io/pixi-viewport/jsdoc/Viewport.html#animate).

I'd be willing to merge the code if you want to create a PR if you're interested.

pspeter3 commented 4 years ago

Thanks! I'll consider adding a PR. How would you want the API to work? A new method or an option to ensureVisible?

davidfig commented 4 years ago

Hmm...probably a findEnsureVisible() that returns an object with x,y,[width,height]. Or something like that. Haven't really thought about it.

pspeter3 commented 4 years ago

OK, I'll go with something like that.