Skip to content

Commit

Permalink
Remove usage of thix.ctx in initDimensions. (#3441)
Browse files Browse the repository at this point in the history
* remove this.ctx at text startup.
* fix textbox
  • Loading branch information
asturur committed Nov 21, 2016
1 parent b0ea87d commit 64f6fd2
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/shapes/textbox.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@
*/
lockScalingFlip: true,

/**
* Override standard Object class values
* Textbox needs this on false
*/
noScaleCache: false,

/**
* Constructor. Some scaling related property values are forced. Visibility
* of controls is also fixed; only the rotation and width controls are
Expand Down Expand Up @@ -96,7 +102,7 @@
this.dynamicMinWidth = 0;

// wrap lines
this._textLines = this._splitTextIntoLines();
this._textLines = this._splitTextIntoLines(ctx);
// if after wrapping, the width is smaller than dynamicMinWidth, change the width and re-wrap
if (this.dynamicMinWidth > this.width) {
this._set('width', this.dynamicMinWidth);
Expand Down Expand Up @@ -320,14 +326,14 @@
* @returns {Array} Array of lines in the Textbox.
* @override
*/
_splitTextIntoLines: function() {
_splitTextIntoLines: function(ctx) {
var originalAlign = this.textAlign;
this.ctx.save();
this._setTextStyles(this.ctx);
ctx.save();
this._setTextStyles(ctx);
this.textAlign = 'left';
var lines = this._wrapText(this.ctx, this.text);
var lines = this._wrapText(ctx, this.text);
this.textAlign = originalAlign;
this.ctx.restore();
ctx.restore();
this._textLines = lines;
this._styleMap = this._generateStyleMap();
return lines;
Expand Down

0 comments on commit 64f6fd2

Please sign in to comment.