hy-virtual-tree 1.1.22 → 1.1.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/index.js +12 -8
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1976,18 +1976,18 @@ class VirtualTree {
|
|
|
1976
1976
|
/** 渲染项 */
|
|
1977
1977
|
const generateItem = (item) => {
|
|
1978
1978
|
const { type, showSelect } = config.rowSelection;
|
|
1979
|
-
|
|
1979
|
+
let el = document.createElement('div');
|
|
1980
1980
|
el.classList.add('hy-tree-node');
|
|
1981
1981
|
if (config.itemGap) {
|
|
1982
1982
|
el.style.paddingBottom = `${config.itemGap}px`;
|
|
1983
1983
|
}
|
|
1984
|
-
|
|
1984
|
+
let nodeContainer = document.createElement('div');
|
|
1985
1985
|
nodeContainer.style.height = `${config.itemHeight}px`;
|
|
1986
1986
|
if (config.nodeBgColor) {
|
|
1987
1987
|
nodeContainer.style.backgroundColor = config.nodeBgColor;
|
|
1988
1988
|
}
|
|
1989
1989
|
setNodeClass(nodeContainer, item);
|
|
1990
|
-
|
|
1990
|
+
let content = document.createElement('div');
|
|
1991
1991
|
content.classList.add('hy-tree-node-content');
|
|
1992
1992
|
content.style.setProperty('padding-left', `${(item.level - 1) * (config.indent || 0)}px`);
|
|
1993
1993
|
// 设备离线 - 字体颜色
|
|
@@ -2132,6 +2132,10 @@ class VirtualTree {
|
|
|
2132
2132
|
}
|
|
2133
2133
|
});
|
|
2134
2134
|
el.appendChild(nodeContainer);
|
|
2135
|
+
this._destroyDomSet.add(() => {
|
|
2136
|
+
// @ts-ignore
|
|
2137
|
+
el = nodeContainer = content = null;
|
|
2138
|
+
});
|
|
2135
2139
|
return el;
|
|
2136
2140
|
};
|
|
2137
2141
|
return { renderItem: generateItem };
|
|
@@ -2189,24 +2193,24 @@ class VirtualTree {
|
|
|
2189
2193
|
let cacheTimer;
|
|
2190
2194
|
let cacheTime = Date.now();
|
|
2191
2195
|
const cacheInterval = 500;
|
|
2192
|
-
|
|
2196
|
+
let cacheData = [];
|
|
2193
2197
|
return async (data, callback) => {
|
|
2194
2198
|
if (!this._tree)
|
|
2195
2199
|
return;
|
|
2196
2200
|
cacheTimer && clearTimeout(cacheTimer);
|
|
2197
2201
|
if (Array.isArray(data)) {
|
|
2198
2202
|
data.forEach((item) => {
|
|
2199
|
-
cacheData.
|
|
2203
|
+
cacheData.push(item);
|
|
2200
2204
|
});
|
|
2201
2205
|
}
|
|
2202
2206
|
else {
|
|
2203
|
-
cacheData.
|
|
2207
|
+
cacheData.push(data);
|
|
2204
2208
|
}
|
|
2205
2209
|
// cacheInterval毫秒仅更新一次数据
|
|
2206
2210
|
if (Date.now() - cacheTime >= cacheInterval) {
|
|
2207
2211
|
cacheTime = Date.now();
|
|
2208
|
-
|
|
2209
|
-
cacheData
|
|
2212
|
+
this._updateTree([...cacheData]);
|
|
2213
|
+
cacheData = [];
|
|
2210
2214
|
this._refreshVirtualScroll();
|
|
2211
2215
|
callback && callback();
|
|
2212
2216
|
}
|