修复 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
*/
ShapesGroup.prototype.setShapes = function(shapes) {
if(this.shapes) {
this.shapes.length = 0;
this.shapes = null;
}
this.shapes = shapes;
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.forEach(function(shape) {
@ -163,9 +170,7 @@ define(
this.editor.coverLayer.clearShapes();
this.editor.coverLayer.refresh();
this.shapes.length = 0;
this.controls.length = 0;
this.shapes = this.controls = this.editor = null;
this.shapes = this.coverShapes = this.controls = this.editor = null;
};
return ShapesGroup;

View File

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

View File

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

View File

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