Browse Source

feat(table): 添加 resizeObserver (#1773)

* feat(table): 添加 resizeObserver

* fix(table): 避免重复创建 observe
pull/1808/head
morning-star 7 months ago committed by GitHub
parent
commit
13b0b42528
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 14
      src/modules/table.js

14
src/modules/table.js

@ -413,7 +413,10 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
that.renderStyle(); that.renderStyle();
// 生成替代元素 // 生成替代元素
hasRender[0] && hasRender.remove(); // 如果已经渲染,则 Rerender if(hasRender[0]){
that.resizeObserver && that.resizeObserver.unobserve(that.elem[0]);
hasRender.remove(); // 如果已经渲染,则 Rerender
}
othis.after(reElem); othis.after(reElem);
// 各级容器 // 各级容器
@ -2704,6 +2707,15 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
e.preventDefault(); e.preventDefault();
that.layMain.scrollTop(scrollTop + (delta > 0 ? -step : step)); that.layMain.scrollTop(scrollTop + (delta > 0 ? -step : step));
}); });
if(window.ResizeObserver){
if(!that.resizeObserver){
that.resizeObserver = new ResizeObserver(function(){
table.resize(that.key);
});
}
that.resizeObserver.observe(that.elem[0]);
}
}; };
// 全局事件 // 全局事件

Loading…
Cancel
Save