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

Added missing functions for pathGroup #3877

Merged
merged 1 commit into from
Apr 24, 2017
Merged
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
46 changes: 46 additions & 0 deletions src/shapes/path_group.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,52 @@
ctx.restore();
},

/**
* Decide if the object should cache or not.
* objectCaching is a global flag, wins over everything
* needsItsOwnCache should be used when the object drawing method requires
* a cache step. None of the fabric classes requires it.
* Generally you do not cache objects in groups because the group outside is cached.
* @return {Boolean}
*/
shouldCache: function() {
var parentCache = this.objectCaching && (!this.group || this.needsItsOwnCache || !this.group.isCaching());
this.caching = parentCache;
if (parentCache) {
for (var i = 0, len = this.paths.length; i < len; i++) {
if (this.paths[i].willDrawShadow()) {
this.caching = false;
return false;
}
}
}
return parentCache;
},

/**
* Check if this object or a child object will cast a shadow
* @return {Boolean}
*/
willDrawShadow: function() {
if (this.shadow) {
return true;
}
for (var i = 0, len = this.paths.length; i < len; i++) {
if (this.paths[i].willDrawShadow()) {
return true;
}
}
return false;
},

/**
* Check if this group or its parent group are caching, recursively up
* @return {Boolean}
*/
isCaching: function() {
return this.caching || this.group && this.group.isCaching();
},

/**
* Check if cache is dirty
*/
Expand Down