From bdb58acf2487620b6895f21e35b599fdb61fe9a7 Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Tue, 3 Mar 2020 11:56:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8C=89=E7=85=A7comment=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/base/tree/ztree/asynctree.js | 3 ++- src/base/tree/ztree/treerender.service.js | 27 ++++++++++++++--------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/base/tree/ztree/asynctree.js b/src/base/tree/ztree/asynctree.js index b492ddbcd..1c6ed5395 100644 --- a/src/base/tree/ztree/asynctree.js +++ b/src/base/tree/ztree/asynctree.js @@ -11,7 +11,8 @@ BI.AsyncTree = BI.inherit(BI.TreeView, { _init: function () { BI.AsyncTree.superclass._init.apply(this, arguments); this.service = new BI.TreeRenderService({ - id: this.id + id: this.id, + container: this.element }); }, diff --git a/src/base/tree/ztree/treerender.service.js b/src/base/tree/ztree/treerender.service.js index dac04f4b3..5789ae16e 100644 --- a/src/base/tree/ztree/treerender.service.js +++ b/src/base/tree/ztree/treerender.service.js @@ -12,10 +12,12 @@ this.id = this.options.id; // renderService是否已经注册了滚动 this.hasBinded = false; + + this.container = this.options.container; }, _getNodeListBounds: function (tId) { - var nodeList = $("#" + this.id + " #" + tId + "_ul")[0]; + var nodeList = BI.$("#" + this.id + " #" + tId + "_ul")[0]; return { top: nodeList.offsetTop, left: nodeList.offsetLeft, @@ -24,14 +26,17 @@ } }, - _getTreeContainerBounds: function() { - var nodeList = $("#" + this.id).parent()[0]; - return { - top: nodeList.offsetTop + nodeList.scrollTop, - left: nodeList.offsetLeft + nodeList.scrollLeft, - width: nodeList.offsetWidth, - height: nodeList.offsetHeight + _getTreeContainerBounds: function () { + var nodeList = this.container[0]; + if (BI.isNotNull(nodeList)) { + return { + top: nodeList.offsetTop + nodeList.scrollTop, + left: nodeList.offsetLeft + nodeList.scrollLeft, + width: nodeList.offsetWidth, + height: nodeList.offsetHeight + }; } + return {}; }, _canNodePopulate: function (tId) { @@ -50,7 +55,7 @@ }, _isNodeInVisible: function (tId) { - var nodeList = $("#" + this.id + " #" + tId + "_ul"); + var nodeList = BI.$("#" + this.id + " #" + tId + "_ul"); return nodeList.length === 0 || nodeList.css("display") === "none"; }, @@ -72,7 +77,7 @@ if(!this.hasBinded) { // console.log("绑定事件"); this.hasBinded = true; - $("#" + this.id).parent().on("scroll", BI.debounce(function () { + this.container && this.container.on("scroll", BI.debounce(function () { self.refreshAllNodes(); }, 30)); } @@ -109,7 +114,7 @@ }); this.nodeLists = {}; // console.log("解绑事件"); - $("#" + this.id).parent().off("scroll"); + this.container.off("scroll"); this.hasBinded = false; } });