Skip to content

Commit

Permalink
MINOR: feat(fabric.Canvas): add getTopContext method to expose the …
Browse files Browse the repository at this point in the history
…internal contextTop (#7697)
  • Loading branch information
ShaMan123 authored Feb 18, 2022
1 parent 03b4c7f commit 043f102
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/canvas.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,14 @@
this.contextTop = upperCanvasEl.getContext('2d');
},

/**
* Returns context of top canvas where interactions are drawn
* @returns {CanvasRenderingContext2D}
*/
getTopContext: function () {
return this.contextTop;
},

/**
* @private
*/
Expand Down
5 changes: 5 additions & 0 deletions test/unit/canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -2527,6 +2527,11 @@

assert.ok(typeof InheritedCanvasClass === 'function');
});

QUnit.test('canvas getTopContext', function(assert) {
assert.ok(typeof canvas.getTopContext === 'function');
assert.equal(canvas.getTopContext(), canvas.contextTop, 'it jsut returns contextTop');
});

QUnit.test('_shouldCenterTransform', function(assert) {
assert.equal(
Expand Down

0 comments on commit 043f102

Please sign in to comment.