KineticjS: Why was the Kinetic.Text verticalAlign property removed? Alternatives?

I use KineticJS text objects with gradient fills, etc. to act like buttons. But now that the verticalAlign property has recently been removed, how do I vertically align text in its bounding box? Why was the property deleted if there are no alternatives?

+6
source share
2 answers

According to this , support has been temporarily removed and hopefully will be added in the near future.

+1
source

The verticalAlign property of the text makes no sense to me.

The text is not kinetic. The container, instead of Kinetic.Shape.

IMO, Kinetic.Shape must not have vertialAlign. He, like a circle, has a verticalAlign. Compatible with what? matched with any container, layer or scene? what am i saying

That's why it is being deleted, I think, and hopefully these properties should be added back to the KineticContainer along with horizontalAlign.

If you want your text to be vertically aligned in a rectangle or circle. At this point, you need to set the y position of your text in order to vertically align it with your container.

If your container is 100 pixels high and your text is 30 pixels high, you will get a y position of 35.

var newY= (box.getHeight()-text.getHeight())/2 text.setY(newY); layer.draw(); 
0
source

All Articles