@@ -227,7 +227,6 @@ export class ListView<T> implements ISpliceable<T>, IDisposable {
227227 private setRowLineHeight : boolean ;
228228 private setRowHeight : boolean ;
229229 private supportDynamicHeights : boolean ;
230- private horizontalScrolling : boolean ;
231230 private additionalScrollHeight : number ;
232231 private accessibilityProvider : ListViewAccessibilityProvider < T > ;
233232 private scrollWidth : number | undefined ;
@@ -249,6 +248,35 @@ export class ListView<T> implements ISpliceable<T>, IDisposable {
249248 get onWillScroll ( ) : Event < ScrollEvent > { return this . scrollableElement . onWillScroll ; }
250249 get containerDomNode ( ) : HTMLElement { return this . rowsContainer ; }
251250
251+ private _horizontalScrolling : boolean = false ;
252+ private get horizontalScrolling ( ) : boolean { return this . _horizontalScrolling ; }
253+ private set horizontalScrolling ( value : boolean ) {
254+ if ( value === this . _horizontalScrolling ) {
255+ return ;
256+ }
257+
258+ if ( value && this . supportDynamicHeights ) {
259+ throw new Error ( 'Horizontal scrolling and dynamic heights not supported simultaneously' ) ;
260+ }
261+
262+ this . _horizontalScrolling = value ;
263+ DOM . toggleClass ( this . domNode , 'horizontal-scrolling' , this . _horizontalScrolling ) ;
264+
265+ if ( this . _horizontalScrolling ) {
266+ for ( const item of this . items ) {
267+ this . measureItemWidth ( item ) ;
268+ }
269+
270+ this . updateScrollWidth ( ) ;
271+ this . scrollableElement . setScrollDimensions ( { width : DOM . getContentWidth ( this . domNode ) } ) ;
272+ this . rowsContainer . style . width = `${ Math . max ( this . scrollWidth || 0 , this . renderWidth ) } px` ;
273+ } else {
274+ this . scrollableElementWidthDelayer . cancel ( ) ;
275+ this . scrollableElement . setScrollDimensions ( { width : this . renderWidth , scrollWidth : this . renderWidth } ) ;
276+ this . rowsContainer . style . width = '' ;
277+ }
278+ }
279+
252280 constructor (
253281 container : HTMLElement ,
254282 private virtualDelegate : IListVirtualDelegate < T > ,
@@ -280,8 +308,8 @@ export class ListView<T> implements ISpliceable<T>, IDisposable {
280308
281309 DOM . toggleClass ( this . domNode , 'mouse-support' , typeof options . mouseSupport === 'boolean' ? options . mouseSupport : true ) ;
282310
283- this . horizontalScrolling = getOrDefault ( options , o => o . horizontalScrolling , DefaultOptions . horizontalScrolling ) ;
284- DOM . toggleClass ( this . domNode , 'horizontal-scrolling' , this . horizontalScrolling ) ;
311+ this . _horizontalScrolling = getOrDefault ( options , o => o . horizontalScrolling , DefaultOptions . horizontalScrolling ) ;
312+ DOM . toggleClass ( this . domNode , 'horizontal-scrolling' , this . _horizontalScrolling ) ;
285313
286314 this . additionalScrollHeight = typeof options . additionalScrollHeight === 'undefined' ? 0 : options . additionalScrollHeight ;
287315
@@ -338,27 +366,8 @@ export class ListView<T> implements ISpliceable<T>, IDisposable {
338366 this . scrollable . setSmoothScrollDuration ( options . smoothScrolling ? 125 : 0 ) ;
339367 }
340368
341- if ( options . horizontalScrolling !== undefined && options . horizontalScrolling !== this . horizontalScrolling ) {
342- if ( options . horizontalScrolling && this . supportDynamicHeights ) {
343- throw new Error ( 'Horizontal scrolling and dynamic heights not supported simultaneously' ) ;
344- }
345-
369+ if ( options . horizontalScrolling !== undefined ) {
346370 this . horizontalScrolling = options . horizontalScrolling ;
347- DOM . toggleClass ( this . domNode , 'horizontal-scrolling' , this . horizontalScrolling ) ;
348-
349- if ( this . horizontalScrolling ) {
350- for ( const item of this . items ) {
351- this . measureItemWidth ( item ) ;
352- }
353-
354- this . updateScrollWidth ( ) ;
355- this . scrollableElement . setScrollDimensions ( { width : DOM . getContentWidth ( this . domNode ) } ) ;
356- this . rowsContainer . style . width = `${ Math . max ( this . scrollWidth || 0 , this . renderWidth ) } px` ;
357- } else {
358- this . scrollableElementWidthDelayer . cancel ( ) ;
359- this . scrollableElement . setScrollDimensions ( { width : this . renderWidth , scrollWidth : this . renderWidth } ) ;
360- this . rowsContainer . style . width = '' ;
361- }
362371 }
363372 }
364373
0 commit comments