mirror of
https://github.com/konvajs/konva.git
synced 2025-09-18 18:27:58 +08:00
added getWidth() and getHeight() methods to Label
This commit is contained in:
@@ -37,13 +37,18 @@
|
|||||||
Kinetic.Group.call(this, config);
|
Kinetic.Group.call(this, config);
|
||||||
this.setText(new Kinetic.Text(config.text));
|
this.setText(new Kinetic.Text(config.text));
|
||||||
this.setRect(new Kinetic.Plugins.LabelRect(config.rect));
|
this.setRect(new Kinetic.Plugins.LabelRect(config.rect));
|
||||||
this.getRect().text = this.getText();
|
|
||||||
this.innerGroup.add(this.getRect());
|
this.innerGroup.add(this.getRect());
|
||||||
this.innerGroup.add(this.getText());
|
this.innerGroup.add(this.getText());
|
||||||
this.add(this.innerGroup);
|
this.add(this.innerGroup);
|
||||||
|
|
||||||
this._setGroupOffset();
|
this._setGroupOffset();
|
||||||
},
|
},
|
||||||
|
getWidth: function() {
|
||||||
|
return this.getText().getWidth();
|
||||||
|
},
|
||||||
|
getHeight: function() {
|
||||||
|
return this.getText().getHeight();
|
||||||
|
},
|
||||||
_setGroupOffset: function() {
|
_setGroupOffset: function() {
|
||||||
var text = this.getText(),
|
var text = this.getText(),
|
||||||
width = text.getWidth(),
|
width = text.getWidth(),
|
||||||
@@ -97,9 +102,10 @@
|
|||||||
this._setDrawFuncs();
|
this._setDrawFuncs();
|
||||||
},
|
},
|
||||||
drawFunc: function(canvas) {
|
drawFunc: function(canvas) {
|
||||||
var context = canvas.getContext(),
|
var label = this.getParent().getParent(),
|
||||||
width = this.text.getWidth(),
|
context = canvas.getContext(),
|
||||||
height = this.text.getHeight(),
|
width = label.getWidth(),
|
||||||
|
height = label.getHeight(),
|
||||||
pointerDirection = this.getPointerDirection(),
|
pointerDirection = this.getPointerDirection(),
|
||||||
pointerWidth = this.getPointerWidth(),
|
pointerWidth = this.getPointerWidth(),
|
||||||
pointerHeight = this.getPointerHeight(),
|
pointerHeight = this.getPointerHeight(),
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
Test.Modules.LABEL = {
|
Test.Modules.LABEL = {
|
||||||
'add label': function(containerId) {
|
'*add label': function(containerId) {
|
||||||
var stage = new Kinetic.Stage({
|
var stage = new Kinetic.Stage({
|
||||||
container: containerId,
|
container: containerId,
|
||||||
width: 578,
|
width: 578,
|
||||||
|
Reference in New Issue
Block a user