修复 cover layer

This commit is contained in:
mkwiser 2014-10-17 00:17:16 +08:00
parent 01b4c8f0d9
commit 23f6f34748
4 changed files with 28 additions and 17 deletions

View File

@ -96,14 +96,21 @@ define(
* 设置操作的shapes * 设置操作的shapes
*/ */
ShapesGroup.prototype.setShapes = function(shapes) { ShapesGroup.prototype.setShapes = function(shapes) {
if(this.shapes) {
this.shapes.length = 0;
this.shapes = null;
}
this.shapes = shapes;
var coverLayer = this.editor.coverLayer; var coverLayer = this.editor.coverLayer;
coverLayer.clearShapes();
if(this.shapes) {
this.shapes = null;
}
if (this.coverShapes) {
this.coverShapes.forEach(function(shape) {
coverLayer.removeShape(shape);
});
this.coverShapes = null;
}
this.shapes = shapes;
this.coverShapes = lang.clone(this.shapes); this.coverShapes = lang.clone(this.shapes);
this.coverShapes.forEach(function(shape) { this.coverShapes.forEach(function(shape) {
@ -163,9 +170,7 @@ define(
this.editor.coverLayer.clearShapes(); this.editor.coverLayer.clearShapes();
this.editor.coverLayer.refresh(); this.editor.coverLayer.refresh();
this.shapes.length = 0; this.shapes = this.coverShapes = this.controls = this.editor = null;
this.controls.length = 0;
this.shapes = this.controls = this.editor = null;
}; };
return ShapesGroup; return ShapesGroup;

View File

@ -74,17 +74,23 @@ define(
} }
else if (command == 'rotate_left') { else if (command == 'rotate_left') {
this.execCommand('rotateleft', shapes); this.execCommand('rotateleft', shapes);
this.currentGroup.setShapes(shapes);
this.currentGroup.refresh(); this.currentGroup.refresh();
} }
else if (command == 'rotate_right') { else if (command == 'rotate_right') {
this.execCommand('rotateright', shapes); this.execCommand('rotateright', shapes);
this.currentGroup.setShapes(shapes);
this.currentGroup.refresh(); this.currentGroup.refresh();
} }
else if (command == 'reverse_shapes') { else if (command == 'reverse_shapes') {
this.execCommand('reverseshapes', shapes); this.execCommand('reverseshapes', shapes);
this.currentGroup.setShapes(shapes);
this.currentGroup.refresh();
} }
else if (command == 'mirror_shapes') { else if (command == 'mirror_shapes') {
this.execCommand('mirrorshapes', shapes); this.execCommand('mirrorshapes', shapes);
this.currentGroup.setShapes(shapes);
this.currentGroup.refresh();
} }
else if (command == 'add_referenceline') { else if (command == 'add_referenceline') {
var bound = this.currentGroup.getBound(); var bound = this.currentGroup.getBound();

View File

@ -206,12 +206,12 @@ define(
id = this.shapes.indexOf(shape); id = this.shapes.indexOf(shape);
} }
else if(typeof shape === 'string') { else if(typeof shape === 'string') {
this.shapes.forEach(function(item, i) { for (var i = 0, l = this.shapes.length; i < l; i++) {
if(item.id === shape) { if (shape == this.shapes[i].id) {
id = i; id = i;
return false; break;
} }
}); }
} }
else if(typeof shape === 'number') { else if(typeof shape === 'number') {
id = shape; id = shape;

View File

@ -168,12 +168,12 @@ define(
id = this.layers.indexOf(layer); id = this.layers.indexOf(layer);
} }
else if(typeof layer === 'string') { else if(typeof layer === 'string') {
this.layers.forEach(function(item, i) { for (var i = 0, l = this.layers.length; i < l; i++) {
if(item.id === layer) { if (layer == this.layers[i].id) {
id = i; id = i;
return false; break;
} }
}); }
} }
else if(typeof id === 'number') { else if(typeof id === 'number') {
id = id; id = id;