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

ApplyFilters updates dirty flag in orde to refresh groups #4828

Merged
merged 5 commits into from
Mar 17, 2018
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
6 changes: 6 additions & 0 deletions src/shapes/image.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,9 @@
scaleX = this.scaleX * retinaScaling,
scaleY = this.scaleY * retinaScaling,
elementToFilter = this._filteredEl || this._originalElement;
if (this.group) {
this.set('dirty', true);
}
if (!filter || (scaleX > minimumScale && scaleY > minimumScale)) {
this._element = elementToFilter;
this._filterScalingX = 1;
Expand Down Expand Up @@ -424,6 +427,9 @@

filters = filters || this.filters || [];
filters = filters.filter(function(filter) { return filter; });
if (this.group) {
this.set('dirty', true);
}
if (filters.length === 0) {
this._element = this._originalElement;
this._filteredEl = null;
Expand Down
26 changes: 26 additions & 0 deletions test/unit/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -645,4 +645,30 @@
done();
});
});

QUnit.test('apply filters do not set the image dirty if not in group', function(assert) {
var done = assert.async();
createImageObject(function(image) {
image.dirty = false;
assert.equal(image.dirty, false, 'false apply filter dirty is false');
image.applyFilters();
assert.equal(image.dirty, false, 'After apply filter dirty is true');
done();
});
});

QUnit.test('apply filters set the image dirty and also the group', function(assert) {
var done = assert.async();
createImageObject(function(image) {
var group = new fabric.Group([image]);
image.dirty = false;
group.dirty = false;
assert.equal(image.dirty, false, 'false apply filter dirty is false');
assert.equal(group.dirty, false, 'false apply filter dirty is false');
image.applyFilters();
assert.equal(image.dirty, true, 'After apply filter dirty is true');
assert.equal(group.dirty, true, 'After apply filter dirty is true');
done();
});
});
})();