Browse Source

按照comment修改

es6
windy 5 years ago
parent
commit
bdb58acf24
  1. 3
      src/base/tree/ztree/asynctree.js
  2. 15
      src/base/tree/ztree/treerender.service.js

3
src/base/tree/ztree/asynctree.js

@ -11,7 +11,8 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
_init: function () { _init: function () {
BI.AsyncTree.superclass._init.apply(this, arguments); BI.AsyncTree.superclass._init.apply(this, arguments);
this.service = new BI.TreeRenderService({ this.service = new BI.TreeRenderService({
id: this.id id: this.id,
container: this.element
}); });
}, },

15
src/base/tree/ztree/treerender.service.js

@ -12,10 +12,12 @@
this.id = this.options.id; this.id = this.options.id;
// renderService是否已经注册了滚动 // renderService是否已经注册了滚动
this.hasBinded = false; this.hasBinded = false;
this.container = this.options.container;
}, },
_getNodeListBounds: function (tId) { _getNodeListBounds: function (tId) {
var nodeList = $("#" + this.id + " #" + tId + "_ul")[0]; var nodeList = BI.$("#" + this.id + " #" + tId + "_ul")[0];
return { return {
top: nodeList.offsetTop, top: nodeList.offsetTop,
left: nodeList.offsetLeft, left: nodeList.offsetLeft,
@ -25,13 +27,16 @@
}, },
_getTreeContainerBounds: function () { _getTreeContainerBounds: function () {
var nodeList = $("#" + this.id).parent()[0]; var nodeList = this.container[0];
if (BI.isNotNull(nodeList)) {
return { return {
top: nodeList.offsetTop + nodeList.scrollTop, top: nodeList.offsetTop + nodeList.scrollTop,
left: nodeList.offsetLeft + nodeList.scrollLeft, left: nodeList.offsetLeft + nodeList.scrollLeft,
width: nodeList.offsetWidth, width: nodeList.offsetWidth,
height: nodeList.offsetHeight height: nodeList.offsetHeight
};
} }
return {};
}, },
_canNodePopulate: function (tId) { _canNodePopulate: function (tId) {
@ -50,7 +55,7 @@
}, },
_isNodeInVisible: function (tId) { _isNodeInVisible: function (tId) {
var nodeList = $("#" + this.id + " #" + tId + "_ul"); var nodeList = BI.$("#" + this.id + " #" + tId + "_ul");
return nodeList.length === 0 || nodeList.css("display") === "none"; return nodeList.length === 0 || nodeList.css("display") === "none";
}, },
@ -72,7 +77,7 @@
if(!this.hasBinded) { if(!this.hasBinded) {
// console.log("绑定事件"); // console.log("绑定事件");
this.hasBinded = true; this.hasBinded = true;
$("#" + this.id).parent().on("scroll", BI.debounce(function () { this.container && this.container.on("scroll", BI.debounce(function () {
self.refreshAllNodes(); self.refreshAllNodes();
}, 30)); }, 30));
} }
@ -109,7 +114,7 @@
}); });
this.nodeLists = {}; this.nodeLists = {};
// console.log("解绑事件"); // console.log("解绑事件");
$("#" + this.id).parent().off("scroll"); this.container.off("scroll");
this.hasBinded = false; this.hasBinded = false;
} }
}); });

Loading…
Cancel
Save