1
1
import Component , { IComponentOptions } from '../share/Component'
2
2
import escape from 'licia/escape'
3
3
import h from 'licia/h'
4
- import types from 'licia/types'
5
4
import throttle from 'licia/throttle'
6
5
import trim from 'licia/trim'
7
6
import isDate from 'licia/isDate'
@@ -76,7 +75,6 @@ interface IInnerEntry extends IBaseEntry {
76
75
* })
77
76
*/
78
77
export default class Logcat extends Component < IOptions > {
79
- private render : types . AnyFn
80
78
private entries : Array < IInnerEntry > = [ ]
81
79
private displayEntries : Array < IInnerEntry > = [ ]
82
80
private removeThreshold = 1
@@ -106,7 +104,6 @@ export default class Logcat extends Component<IOptions> {
106
104
this . removeThreshold = Math . round ( maxNum / 10 )
107
105
}
108
106
109
- this . render = throttle ( ( ) => this . _render ( ) , 16 )
110
107
if ( this . options . entries ) {
111
108
each ( this . options . entries , ( entry ) => {
112
109
this . append ( entry )
@@ -240,6 +237,7 @@ export default class Logcat extends Component<IOptions> {
240
237
} else {
241
238
this . $container . rmClass ( c ( 'wrap-long-lines' ) )
242
239
}
240
+ this . virtualList . update ( )
243
241
break
244
242
case 'maxNum' :
245
243
if ( val > 0 && entries . length > val ) {
@@ -256,6 +254,7 @@ export default class Logcat extends Component<IOptions> {
256
254
257
255
entry . container . innerHTML = html
258
256
} )
257
+ this . virtualList . update ( )
259
258
break
260
259
case 'filter' :
261
260
this . displayEntries = [ ]
@@ -317,18 +316,15 @@ export default class Logcat extends Component<IOptions> {
317
316
`<span class="${ c ( 'message' ) } ">${ escape ( trim ( entry . message ) ) } </span>` ,
318
317
] . join ( ' ' )
319
318
}
320
- private _render ( ) {
321
- const { container } = this
322
- this . $container . html ( '' )
323
-
324
- const frag = document . createDocumentFragment ( )
319
+ private render = throttle ( ( ) => {
320
+ const items : HTMLElement [ ] = [ ]
325
321
each ( this . displayEntries , ( entry ) => {
326
- frag . appendChild ( entry . container )
322
+ items . push ( entry . container )
327
323
} )
328
- container . appendChild ( frag )
324
+ this . virtualList . setItems ( items )
329
325
330
326
this . scrollToEnd ( )
331
- }
327
+ } , 16 )
332
328
}
333
329
334
330
function toLetter ( priority : number ) {
0 commit comments