@@ -9,8 +9,8 @@ import { Gesture, EventType as TouchEventType, GestureEvent } from 'vs/base/brow
99import * as DOM from 'vs/base/browser/dom' ;
1010import { Event , Emitter } from 'vs/base/common/event' ;
1111import { domEvent } from 'vs/base/browser/event' ;
12- import { ScrollableElement } from 'vs/base/browser/ui/scrollbar/scrollableElement' ;
13- import { ScrollEvent , ScrollbarVisibility , INewScrollDimensions } from 'vs/base/common/scrollable' ;
12+ import { SmoothScrollableElement } from 'vs/base/browser/ui/scrollbar/scrollableElement' ;
13+ import { ScrollEvent , ScrollbarVisibility , INewScrollDimensions , Scrollable } from 'vs/base/common/scrollable' ;
1414import { RangeMap , shift } from './rangeMap' ;
1515import { IListVirtualDelegate , IListRenderer , IListMouseEvent , IListTouchEvent , IListGestureEvent , IListDragEvent , IListDragAndDrop , ListDragOverEffect } from './list' ;
1616import { RowCache , IRow } from './rowCache' ;
@@ -48,7 +48,12 @@ export interface IListViewAccessibilityProvider<T> {
4848 isChecked ?( element : T ) : boolean | undefined ;
4949}
5050
51- export interface IListViewOptions < T > {
51+ export interface IListViewOptionsUpdate {
52+ readonly additionalScrollHeight ?: number ;
53+ readonly smoothScrolling ?: boolean ;
54+ }
55+
56+ export interface IListViewOptions < T > extends IListViewOptionsUpdate {
5257 readonly dnd ?: IListViewDragAndDrop < T > ;
5358 readonly useShadows ?: boolean ;
5459 readonly verticalScrollMode ?: ScrollbarVisibility ;
@@ -58,7 +63,6 @@ export interface IListViewOptions<T> {
5863 readonly mouseSupport ?: boolean ;
5964 readonly horizontalScrolling ?: boolean ;
6065 readonly accessibilityProvider ?: IListViewAccessibilityProvider < T > ;
61- readonly additionalScrollHeight ?: number ;
6266 readonly transformOptimization ?: boolean ;
6367}
6468
@@ -204,7 +208,8 @@ export class ListView<T> implements ISpliceable<T>, IDisposable {
204208 private lastRenderHeight : number ;
205209 private renderWidth = 0 ;
206210 private rowsContainer : HTMLElement ;
207- private scrollableElement : ScrollableElement ;
211+ private scrollable : Scrollable ;
212+ private scrollableElement : SmoothScrollableElement ;
208213 private _scrollHeight : number = 0 ;
209214 private scrollableElementUpdateDisposable : IDisposable | null = null ;
210215 private scrollableElementWidthDelayer = new Delayer < void > ( 50 ) ;
@@ -285,12 +290,13 @@ export class ListView<T> implements ISpliceable<T>, IDisposable {
285290
286291 this . disposables . add ( Gesture . addTarget ( this . rowsContainer ) ) ;
287292
288- this . scrollableElement = this . disposables . add ( new ScrollableElement ( this . rowsContainer , {
293+ this . scrollable = new Scrollable ( getOrDefault ( options , o => o . smoothScrolling , false ) ? 125 : 0 , cb => DOM . scheduleAtNextAnimationFrame ( cb ) ) ;
294+ this . scrollableElement = this . disposables . add ( new SmoothScrollableElement ( this . rowsContainer , {
289295 alwaysConsumeMouseWheel : true ,
290296 horizontal : this . horizontalScrolling ? ScrollbarVisibility . Auto : ScrollbarVisibility . Hidden ,
291297 vertical : getOrDefault ( options , o => o . verticalScrollMode , DefaultOptions . verticalScrollMode ) ,
292- useShadows : getOrDefault ( options , o => o . useShadows , DefaultOptions . useShadows )
293- } ) ) ;
298+ useShadows : getOrDefault ( options , o => o . useShadows , DefaultOptions . useShadows ) ,
299+ } , this . scrollable ) ) ;
294300
295301 this . domNode . appendChild ( this . scrollableElement . getDomNode ( ) ) ;
296302 container . appendChild ( this . domNode ) ;
@@ -320,6 +326,10 @@ export class ListView<T> implements ISpliceable<T>, IDisposable {
320326 if ( options . additionalScrollHeight !== undefined ) {
321327 this . additionalScrollHeight = options . additionalScrollHeight ;
322328 }
329+
330+ if ( options . smoothScrolling !== undefined ) {
331+ this . scrollable . setSmoothScrollDuration ( options . smoothScrolling ? 125 : 0 ) ;
332+ }
323333 }
324334
325335 triggerScrollFromMouseWheelEvent ( browserEvent : IMouseWheelEvent ) {
0 commit comments