Skip to content

Commit

Permalink
removed this.ctx (#4466)
Browse files Browse the repository at this point in the history
  • Loading branch information
asturur authored Nov 17, 2017
1 parent c975247 commit 0df3f55
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
7 changes: 4 additions & 3 deletions src/mixins/itext_behavior.mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@
* Aborts cursor animation and clears all timeouts
*/
abortCursorAnimation: function() {
var shouldClear = this._currentTickState || this._currentTickCompleteState;
var shouldClear = this._currentTickState || this._currentTickCompleteState,
canvas = this.canvas;
this._currentTickState && this._currentTickState.abort();
this._currentTickCompleteState && this._currentTickCompleteState.abort();

Expand All @@ -161,8 +162,8 @@
this._currentCursorOpacity = 0;
// to clear just itext area we need to transform the context
// it may not be worth it
if (shouldClear) {
this.canvas && this.canvas.clearContext(this.canvas.contextTop || this.ctx);
if (shouldClear && canvas) {
canvas.clearContext(canvas.contextTop || canvas.contextContainer);
}

},
Expand Down
5 changes: 2 additions & 3 deletions src/shapes/itext.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@
*/
_render: function(ctx) {
this.callSuper('_render', ctx);
this.ctx = ctx;
},

/**
Expand All @@ -280,7 +279,7 @@
* Renders cursor or selection (depending on what exists)
*/
renderCursorOrSelection: function() {
if (!this.isEditing) {
if (!this.isEditing || !this.canvas) {
return;
}
var boundaries = this._getCursorBoundaries(), ctx;
Expand All @@ -289,7 +288,7 @@
this.clearContextTop(true);
}
else {
ctx = this.ctx;
ctx = this.canvas.contextContainer;
ctx.save();
}
if (this.selectionStart === this.selectionEnd) {
Expand Down
1 change: 0 additions & 1 deletion src/shapes/textbox.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
*/
initialize: function(text, options) {
this.callSuper('initialize', text, options);
this.ctx = this.objectCaching ? this._cacheContext : fabric.util.createCanvasElement().getContext('2d');
},

/**
Expand Down

0 comments on commit 0df3f55

Please sign in to comment.