changing the font size now correctly updates the text data

This commit is contained in:
Eric Rowell 2012-07-31 21:13:25 -07:00
parent b7ac415ea6
commit ed8c5ab6b8
4 changed files with 39 additions and 3 deletions

View File

@ -4883,7 +4883,7 @@ Kinetic.Text = Kinetic.Shape.extend({
this._super(config);
// update text data for certain attr changes
var attrs = ['width', 'height', 'padding', 'text', 'textStroke', 'textStrokeWidth'];
var attrs = ['fontFamily', 'fontSize', 'fontStyle', 'padding', 'align', 'lineHeight', 'text', 'width', 'height'];
var that = this;
for(var n = 0; n < attrs.length; n++) {
var attr = attrs[n];

File diff suppressed because one or more lines are too long

View File

@ -32,7 +32,7 @@ Kinetic.Text = Kinetic.Shape.extend({
this._super(config);
// update text data for certain attr changes
var attrs = ['width', 'height', 'padding', 'text', 'textStroke', 'textStrokeWidth'];
var attrs = ['fontFamily', 'fontSize', 'fontStyle', 'padding', 'align', 'lineHeight', 'text', 'width', 'height'];
var that = this;
for(var n = 0; n < attrs.length; n++) {
var attr = attrs[n];

View File

@ -2847,6 +2847,42 @@ Test.prototype.tests = {
});
*/
},
'SHAPE - change font size should update text data': function(containerId) {
var stage = new Kinetic.Stage({
container: containerId,
width: 578,
height: 200
});
var layer = new Kinetic.Layer();
var text = new Kinetic.Text({
x: 10,
y: 10,
fill: '#ddd',
text: 'Some awesome text',
fontSize: 16,
fontFamily: 'Calibri',
fontStyle: 'normal',
textFill: '#555',
align: 'center',
padding: 5,
draggable: true,
detectionType: 'path'
});
var width = text.getBoxWidth();
var height = text.getBoxHeight();
layer.add(text);
stage.add(layer);
text.setFontSize(30);
layer.draw();
test(text.getBoxWidth() > width, 'text box width should have increased.');
test(text.getBoxHeight() > height, 'text box height should have increased.');
},
'SHAPE - get shape name': function(containerId) {
var stage = new Kinetic.Stage({
container: containerId,