From 0d36e565a954d57fe033f533f2a68e5450b0298a Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Thu, 7 Sep 2017 09:39:00 +0200 Subject: [PATCH] improved docs, fixed dirty on group destroy (#4293) --- src/mixins/collection.mixin.js | 6 ++++++ src/shapes/group.class.js | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/src/mixins/collection.mixin.js b/src/mixins/collection.mixin.js index 48fa7319c85..df7752c87c6 100644 --- a/src/mixins/collection.mixin.js +++ b/src/mixins/collection.mixin.js @@ -10,6 +10,9 @@ fabric.Collection = { * (if `renderOnAddRemove` is not `false`). * in case of Group no changes to bounding box are made. * Objects should be instances of (or inherit from) fabric.Object + * Use of this function is highly discouraged for groups. + * you can add a bunch of objects with the add method but then you NEED + * to run a addWithUpdate call for the Group class or position/bbox will be wrong. * @param {...fabric.Object} object Zero or more fabric instances * @return {Self} thisArg * @chainable @@ -28,6 +31,9 @@ fabric.Collection = { /** * Inserts an object into collection at specified index, then renders canvas (if `renderOnAddRemove` is not `false`) * An object should be an instance of (or inherit from) fabric.Object + * Use of this function is highly discouraged for groups. + * you can add a bunch of objects with the insertAt method but then you NEED + * to run a addWithUpdate call for the Group class or position/bbox will be wrong. * @param {Object} object Object to insert * @param {Number} index Index to insert object at * @param {Boolean} nonSplicing When `true`, no splicing (shifting) of objects occurs diff --git a/src/shapes/group.class.js b/src/shapes/group.class.js index 29cb2d16243..6408646b40d 100644 --- a/src/shapes/group.class.js +++ b/src/shapes/group.class.js @@ -393,6 +393,11 @@ * @chainable */ destroy: function() { + // when group is destroyed objects needs to get a repaint to be eventually + // displayed on canvas. + this._objects.forEach(function(object) { + object.set('dirty', true); + }); return this._restoreObjectsState(); },