Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix itext cursor trail on initDimensions #3436

Merged
merged 2 commits into from
Nov 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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