Skip to content

Commit

Permalink
Fix itext cursor trail on initDimensions (#3436)
Browse files Browse the repository at this point in the history
* add clear context top for set

* fix cursor trail
  • Loading branch information
asturur committed Nov 20, 2016
1 parent 52013a9 commit a5245b9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
15 changes: 15 additions & 0 deletions src/shapes/itext.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,21 @@
fabric.util.object.extend(this._getStyleDeclaration(loc.lineIndex, loc.charIndex), styles);
},

/**
* Initialize text dimensions. Render all text on given context
* or on a offscreen canvas to get the text width with measureText.
* Updates this.width and this.height with the proper values.
* Does not return dimensions.
* @param {CanvasRenderingContext2D} [ctx] Context to render on
* @private
*/
_initDimensions: function(ctx) {
if (!ctx) {
this.clearContextTop();
}
this.callSuper('_initDimensions', ctx);
},

/**
* @private
* @param {CanvasRenderingContext2D} ctx Context to render on
Expand Down
10 changes: 5 additions & 5 deletions src/shapes/object.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@
* @type Boolean
* @default
*/
statefullCache: false,
statefullCache: true,

/**
* When `true`, cache does not get updated during scaling. The picture will get blocky if scaled
Expand Down Expand Up @@ -851,10 +851,10 @@
dim = this._getNonTransformedDimensions(),
retina = this.canvas && this.canvas._isRetinaScaling() ? fabric.devicePixelRatio : 1,
zoomX = objectScale.scaleX * zoom * retina,
zoomY = objectScale.scaleY * zoom * retina;
if (zoomX !== this.zoomX || zoomY !== this.zoomY) {
var width = dim.x * zoomX,
height = dim.y * zoomY;
zoomY = objectScale.scaleY * zoom * retina,
width = dim.x * zoomX,
height = dim.y * zoomY;
if (width !== this.cacheWidth || height !== this.cacheHeight) {
this._cacheCanvas.width = width;
this._cacheCanvas.height = height;
this._cacheContext.translate(width / 2, height / 2);
Expand Down

0 comments on commit a5245b9

Please sign in to comment.