diff --git a/js/edit.js b/js/edit.js index c930f74e..846917e3 100644 --- a/js/edit.js +++ b/js/edit.js @@ -90,7 +90,7 @@ function EDIT_CLASS() { } return false; } - + LAYER.layer_max_index++; tmp = new Array(); var new_name = LAYER.generate_layer_name(); LAYER.create_canvas(new_name); @@ -150,6 +150,7 @@ function EDIT_CLASS() { return false; } + EDIT.edit_clear(); LAYER.remove_all_layers(); if (WIDTH != layers_archive[j].width || HEIGHT != layers_archive[j].height) { diff --git a/js/layers.js b/js/layers.js index 0c68836e..79e66b44 100644 --- a/js/layers.js +++ b/js/layers.js @@ -23,7 +23,7 @@ function LAYER_CLASS() { /** * latest layer index */ - var layer_max_index = 0; + this.layer_max_index = 0; //new layer this.layer_new = function () { @@ -56,7 +56,7 @@ function LAYER_CLASS() { for (var i = LAYER.layers.length-1; i >= 0; i--) { LAYER.layer_remove(i, true); } - layer_max_index = 0; + this.layer_max_index = 0; this.layer_renew(); }; @@ -65,12 +65,12 @@ function LAYER_CLASS() { if(prefix == undefined) prefix = 'Layer'; - return prefix + ' #' + (layer_max_index); + return prefix + ' #' + (this.layer_max_index); }; //create layer this.layer_add = function (name, data, layer_type, layer_extra_info) { - layer_max_index++; + this.layer_max_index++; if(layer_type == undefined) layer_type = 'default'; @@ -182,6 +182,7 @@ function LAYER_CLASS() { if (this.layers.length == 1 && force == undefined){ //only 1 layer left canvas_active().clearRect(0, 0, WIDTH, HEIGHT); + GUI.redraw_preview(); return false; } element = document.getElementById(this.layers[i].name); @@ -208,7 +209,7 @@ function LAYER_CLASS() { LAYER.layer_renew(); } else { - layer_max_index++; + this.layer_max_index++; //copy all layer tmp_data = document.createElement("canvas"); tmp_data.width = WIDTH;