fix/fixed-table-rowHeight-sync
sight 2025-09-07 17:36:49 +08:00
parent 208cadbc4b
commit 8908d68bf3
2 changed files with 10 additions and 6 deletions

View File

@ -365,8 +365,8 @@ layui.define(['i18n', 'jquery', 'laytpl', 'lay', 'util'], function(exports) {
});
if(resizeObserver){
resizeObserver.observe(options.elem[0], that.position.bind(that));
resizeObserver.observe(mainElem[0], that.position.bind(that));
resizeObserver.observe(options.elem[0], $.proxy(that.position, that));
resizeObserver.observe(mainElem[0], $.proxy(that.position, that));
}
// 组件打开完毕的事件

View File

@ -2977,14 +2977,18 @@ layui.define(['lay', 'i18n', 'laytpl', 'laypage', 'form', 'util'], function(expo
if(!that.resizeObserver) return;
// 显示或隐藏时重置列宽
that.resizeObserver.observe(that.elem[0], that.resize.bind(that));
that.resizeObserver.observe(that.elem[0], $.proxy(that.resize, that));
// 同步固定列表格和主表格高度
that.needSyncFixedColHeight = that.config.syncFixedRowHeight && (that.layBody.length > 1)
var lineStyle = that.config.lineStyle;
var isAutoHeight = lineStyle && (/\bheight\s*:\s*auto\b/g.test(lineStyle) || lineStyle.indexOf('max-height') !== -1);
that.needSyncFixedColHeight = (that.layBody.length > 1) && (that.config.syncFixedRowHeight || (that.config.syncFixedRowHeight !== false && isAutoHeight));
if(that.needSyncFixedColHeight){
var tableElem = that.layMain.children('table');
that.resizeObserver.observe(tableElem[0], that.syncFixedColHeight.bind(that));
that.resizeObserver.observe(
that.layMain.children('table')[0],
$.proxy(that.syncFixedColHeight, that)
);
}
};