@@ -51,6 +51,7 @@ export function reset(id) {
51
51
52
52
const shim = [ ...table . el . children ] . find ( i => i . classList . contains ( 'table-shim' ) )
53
53
if ( shim !== void 0 ) {
54
+ table . shim = shim ;
54
55
table . thead = [ ...shim . children ] . find ( i => i . classList . contains ( 'table-fixed-header' ) )
55
56
table . isResizeColumn = shim . classList . contains ( 'table-resize' )
56
57
if ( table . thead ) {
@@ -102,13 +103,23 @@ export function reset(id) {
102
103
103
104
table . pages = [ ...table . el . children ] . find ( i => i . classList . contains ( 'nav-pages' ) ) ;
104
105
105
- setBodyHeight ( table )
106
106
107
107
setColumnToolboxListener ( table ) ;
108
108
109
+ if ( isVisible ( table . el ) === false ) {
110
+ table . loopCheckHeightHandler = requestAnimationFrame ( ( ) => check ( table ) ) ;
111
+ return ;
112
+ }
113
+
114
+ observeHeight ( table )
115
+ }
116
+
117
+ const observeHeight = table => {
118
+ setBodyHeight ( table ) ;
119
+
109
120
const observer = new ResizeObserver ( entries => {
110
121
entries . forEach ( entry => {
111
- if ( entry . target === shim ) {
122
+ if ( entry . target === table . shim ) {
112
123
setTableDefaultWidth ( table ) ;
113
124
}
114
125
else if ( entry . target === table . search || entry . target === table . toolbar || entry . target === table . pages ) {
@@ -117,7 +128,7 @@ export function reset(id) {
117
128
} ) ;
118
129
} ) ;
119
130
if ( table . thead ) {
120
- observer . observe ( shim ) ;
131
+ observer . observe ( table . shim ) ;
121
132
}
122
133
if ( table . search ) {
123
134
observer . observe ( table . search ) ;
@@ -280,18 +291,16 @@ const check = table => {
280
291
table . loopCheckHeightHandler = requestAnimationFrame ( ( ) => check ( table ) ) ;
281
292
}
282
293
else {
283
- delete table . loopCheckHeightHandler ;
284
- setBodyHeight ( table ) ;
294
+ if ( table . loopCheckHeightHandler > 0 ) {
295
+ cancelAnimationFrame ( table . loopCheckHeightHandler ) ;
296
+ delete table . loopCheckHeightHandler ;
297
+ }
298
+ observeHeight ( table ) ;
285
299
}
286
300
} ;
287
301
288
302
const setBodyHeight = table => {
289
303
const el = table . el
290
- if ( isVisible ( el ) === false ) {
291
- table . loopCheckHeightHandler = requestAnimationFrame ( ( ) => check ( table ) ) ;
292
- return ;
293
- }
294
-
295
304
const children = [ ...el . children ]
296
305
const search = children . find ( i => i . classList . contains ( 'table-search' ) )
297
306
table . search = search ;
0 commit comments