修复属性面板修改名称,无法记住树节点展开状态的bug。

This commit is contained in:
tengge1 2019-03-10 21:19:33 +08:00
parent 9bf5cfce7a
commit dd09ee7176
3 changed files with 7 additions and 3 deletions

View File

@ -8,7 +8,8 @@ Language: 中文 / [English](README-en.md)
## v0.1.7即将更新
1. 修复属性面板修改名称无法及时响应问题。
1. 修复属性面板修改名称场景树状图无法及时响应的bug。
2. 修复属性面板修改名称无法记住树节点展开状态的bug。
## v0.1.6更新

View File

@ -41,7 +41,7 @@ HierachyPanel.prototype.render = function () {
this.app.on(`sceneGraphChanged.${this.id}`, this.updateUI.bind(this));
// bug: https://gitee.com/tengge1/ShadowEditor/issues/ITCCT
// bug: https://gitee.com/tengge1/ShadowEditor/issues/ITCA9
this.app.on(`objectChanged.${this.id}`, this.updateUI.bind(this));
this.app.on(`objectSelected.${this.id}`, this.onObjectSelected.bind(this));

View File

@ -17,6 +17,7 @@ function Tree(options = {}) {
this._selected = null;
this._nodes = {}; // value: li
this._expands = {}; // value: true/false, 记录每个节点展开关闭状态
};
Tree.prototype = Object.create(Control.prototype);
@ -49,7 +50,7 @@ Tree.prototype._createNode = function (data, dom) {
var value = data.value || '';
var leaf = !Array.isArray(data.children) || data.children.length === 0;
var expand = data.expand || false;
var expand = data.expand || this._expands[value] === true;
var draggable = data.draggable || false;
data.leaf = leaf;
@ -177,6 +178,7 @@ Tree.prototype.expand = function (value) {
}
data.expand = true;
this._expands[data.value] = true;
for (var i = 0; i < li.children.length; i++) {
var node = li.children[i];
@ -206,6 +208,7 @@ Tree.prototype.collapse = function (value) {
}
data.expand = false;
this._expands[data.value] = false;
for (var i = 0; i < li.children.length; i++) {
var node = li.children[i];