added getWidth() and getHeight() methods to Label

This commit is contained in:
Eric Rowell
2013-03-17 17:56:39 -07:00
parent b37f50ba69
commit e0e390f760
2 changed files with 11 additions and 5 deletions

View File

@@ -37,13 +37,18 @@
Kinetic.Group.call(this, config);
this.setText(new Kinetic.Text(config.text));
this.setRect(new Kinetic.Plugins.LabelRect(config.rect));
this.getRect().text = this.getText();
this.innerGroup.add(this.getRect());
this.innerGroup.add(this.getText());
this.add(this.innerGroup);
this._setGroupOffset();
},
getWidth: function() {
return this.getText().getWidth();
},
getHeight: function() {
return this.getText().getHeight();
},
_setGroupOffset: function() {
var text = this.getText(),
width = text.getWidth(),
@@ -97,9 +102,10 @@
this._setDrawFuncs();
},
drawFunc: function(canvas) {
var context = canvas.getContext(),
width = this.text.getWidth(),
height = this.text.getHeight(),
var label = this.getParent().getParent(),
context = canvas.getContext(),
width = label.getWidth(),
height = label.getHeight(),
pointerDirection = this.getPointerDirection(),
pointerWidth = this.getPointerWidth(),
pointerHeight = this.getPointerHeight(),

View File

@@ -1,5 +1,5 @@
Test.Modules.LABEL = {
'add label': function(containerId) {
'*add label': function(containerId) {
var stage = new Kinetic.Stage({
container: containerId,
width: 578,