Browse Source

按照comment修改

es6
windy 5 years ago
parent
commit
bdb58acf24
  1. 3
      src/base/tree/ztree/asynctree.js
  2. 27
      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
}); });
}, },

27
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,
@ -24,14 +26,17 @@
} }
}, },
_getTreeContainerBounds: function() { _getTreeContainerBounds: function () {
var nodeList = $("#" + this.id).parent()[0]; var nodeList = this.container[0];
return { if (BI.isNotNull(nodeList)) {
top: nodeList.offsetTop + nodeList.scrollTop, return {
left: nodeList.offsetLeft + nodeList.scrollLeft, top: nodeList.offsetTop + nodeList.scrollTop,
width: nodeList.offsetWidth, left: nodeList.offsetLeft + nodeList.scrollLeft,
height: nodeList.offsetHeight width: nodeList.offsetWidth,
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