Browse Source

Pull request #2233: 无JIRA任务 换一种实现,以插入nextSibling兄弟节点前的思路实现

Merge in VISUAL/fineui from ~GUY/fineui:master to master

* commit '05baf7638c1e450fa2b5ff732a862cc0fd1d4d67':
  换一种实现,以插入nextSibling兄弟节点前的思路实现
es6
guy 3 years ago
parent
commit
9cfc230c6b
  1. 14
      src/core/wrapper/layout.js

14
src/core/wrapper/layout.js

@ -240,10 +240,11 @@ BI.Layout = BI.inherit(BI.Widget, {
var w = this._newElement(newIndex, item);
// 需要有个地方临时存一下新建的组件,否则如果直接使用newIndex的话,newIndex位置的元素可能会被用到
this._children[this._getChildName(newIndex) + "-temp"] = w;
if (oldIndex > 0) {
this._children[this._getChildName(oldIndex - 1)].element.after(w.element);
var nextSibling = del.element[0].nextSibling;
if (nextSibling) {
BI.Widget._renderEngine.createElement(nextSibling).before(w.element);
} else {
w.element.prependTo(this._getWrapper());
w.element.appendTo(this._getWrapper());
}
del._destroy();
w._mount();
@ -308,10 +309,11 @@ BI.Layout = BI.inherit(BI.Widget, {
}
this._addItemAt(index, item);
var w = this._addElement(index, item);
if (index > 0) {
this._children[this._getChildName(index - 1)].element.after(w.element);
var nextSibling = this._children[this._getChildName(index)].element[0].nextSibling;
if (nextSibling) {
BI.Widget._renderEngine.createElement(nextSibling).before(w.element);
} else {
w.element.prependTo(this._getWrapper());
w.element.appendTo(this._getWrapper());
}
w._mount();
return w;

Loading…
Cancel
Save