@@ -27,8 +27,11 @@ class Clusterize extends EventEmitter {
2727 } ;
2828
2929 scrollElement = null ;
30+
3031 contentElement = null ;
32+
3133 rows = [ ] ;
34+
3235 cache = { } ;
3336
3437 scrollEventListener = ( ( ) => {
@@ -128,13 +131,15 @@ class Clusterize extends EventEmitter {
128131 addEventListener ( this . scrollElement , 'scroll' , this . scrollEventListener ) ;
129132 addEventListener ( window , 'resize' , this . resizeEventListener ) ;
130133 }
134+
131135 destroy ( clean ) {
132136 removeEventListener ( this . scrollElement , 'scroll' , this . scrollEventListener ) ;
133137 removeEventListener ( window , 'resize' , this . resizeEventListener ) ;
134138
135139 const rows = clean ? this . generateEmptyRow ( ) : this . rows ( ) ;
136140 this . setContent ( rows . join ( '' ) ) ;
137141 }
142+
138143 update ( rows ) {
139144 this . rows = ensureArray ( rows ) ;
140145
@@ -150,10 +155,12 @@ class Clusterize extends EventEmitter {
150155 // Restore scroll position
151156 this . scrollElement . scrollTop = scrollTop ;
152157 }
158+
153159 clear ( ) {
154160 this . rows = [ ] ;
155161 this . update ( ) ;
156162 }
163+
157164 append ( rows ) {
158165 rows = ensureArray ( rows ) ;
159166 if ( ! rows . length ) {
@@ -162,6 +169,7 @@ class Clusterize extends EventEmitter {
162169 this . rows = this . rows . concat ( rows ) ;
163170 this . changeDOM ( ) ;
164171 }
172+
165173 prepend ( rows ) {
166174 rows = ensureArray ( rows ) ;
167175 if ( ! rows . length ) {
@@ -170,6 +178,7 @@ class Clusterize extends EventEmitter {
170178 this . rows = rows . concat ( this . rows ) ;
171179 this . changeDOM ( ) ;
172180 }
181+
173182 computeHeight ( ) {
174183 if ( ! this . rows . length ) {
175184 return {
@@ -203,13 +212,15 @@ class Clusterize extends EventEmitter {
203212 } ;
204213 }
205214 }
215+
206216 getCurrentClusterIndex ( ) {
207217 const { blockHeight, clusterHeight } = this . state ;
208218 if ( ! blockHeight || ! clusterHeight ) {
209219 return 0 ;
210220 }
211221 return Math . floor ( this . scrollElement . scrollTop / ( clusterHeight - blockHeight ) ) || 0 ;
212222 }
223+
213224 generateEmptyRow ( ) {
214225 const { tag, emptyText, emptyClass } = this . options ;
215226
@@ -231,6 +242,7 @@ class Clusterize extends EventEmitter {
231242
232243 return [ emptyRow . outerHTML ] ;
233244 }
245+
234246 renderExtraTag ( className , height ) {
235247 const tag = document . createElement ( this . options . tag ) ;
236248 const prefix = 'infinite-tree-' ;
@@ -246,6 +258,7 @@ class Clusterize extends EventEmitter {
246258
247259 return tag . outerHTML ;
248260 }
261+
249262 changeDOM ( ) {
250263 if ( ! this . state . clusterHeight && this . rows . length > 0 ) {
251264 if ( ie && ie <= 9 && ! this . options . tag ) {
@@ -312,6 +325,7 @@ class Clusterize extends EventEmitter {
312325 this . contentElement . lastChild . style . height = bottomOffset + 'px' ;
313326 }
314327 }
328+
315329 setContent ( content ) {
316330 // For IE 9 and older versions
317331 if ( ie && ie <= 9 && this . options . tag === 'tr' ) {
@@ -332,6 +346,7 @@ class Clusterize extends EventEmitter {
332346 this . contentElement . innerHTML = content ;
333347 }
334348 }
349+
335350 getChildNodes ( tag ) {
336351 const childNodes = tag . children ;
337352 const nodes = [ ] ;
@@ -343,6 +358,7 @@ class Clusterize extends EventEmitter {
343358
344359 return nodes ;
345360 }
361+
346362 checkChanges ( type , value ) {
347363 const changed = ( value !== this . cache [ type ] ) ;
348364 this . cache [ type ] = value ;
0 commit comments