Use insert: false option in creation of all clones.

Still needs implementing in Item constructor.
This commit is contained in:
Jürg Lehni 2013-07-19 18:42:13 -07:00
parent cfbd356247
commit b7aea1e527
4 changed files with 18 additions and 8 deletions

View file

@ -99,7 +99,10 @@ var PlacedSymbol = Item.extend(/** @lends PlacedSymbol# */{
}, },
clone: function(insert) { clone: function(insert) {
return this._clone(new PlacedSymbol(this.symbol), insert); return this._clone(new PlacedSymbol({
symbol: this.symbol,
insert: false
}), insert);
}, },
isEmpty: function() { isEmpty: function() {

View file

@ -94,14 +94,17 @@ var Raster = Item.extend(/** @lends Raster# */{
}, },
clone: function(insert) { clone: function(insert) {
var element = this._image; var param = { insert: false },
if (!element) { image = this._image;
if (image) {
param.image = image;
} else {
// If the Raster contains a Canvas object, we need to create // If the Raster contains a Canvas object, we need to create
// a new one and draw this raster's canvas on it. // a new one and draw this raster's canvas on it.
element = CanvasProvider.getCanvas(this._size); var canvas = param.canvas = CanvasProvider.getCanvas(this._size);
element.getContext('2d').drawImage(this._canvas, 0, 0); canvas.getContext('2d').drawImage(this._canvas, 0, 0);
} }
return this._clone(new Raster(element), insert); return this._clone(new Raster(param), insert);
}, },
/** /**

View file

@ -91,7 +91,11 @@ var Path = PathItem.extend(/** @lends Path# */{
}, },
clone: function(insert) { clone: function(insert) {
var copy = this._clone(new Path(this._segments), insert); var copy = this._clone(new Path({
segments: this._segments,
insert: false
}), insert);
// Speed up things a little by copy over values that don't need checking
copy._closed = this._closed; copy._closed = this._closed;
if (this._clockwise !== undefined) if (this._clockwise !== undefined)
copy._clockwise = this._clockwise; copy._clockwise = this._clockwise;

View file

@ -48,7 +48,7 @@ var PointText = TextItem.extend(/** @lends PointText# */{
}, },
clone: function(insert) { clone: function(insert) {
return this._clone(new PointText(), insert); return this._clone(new PointText({ insert: false }), insert);
}, },
/** /**