File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed
Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change 379379 } ,
380380
381381 scrollToActive : function ( ) {
382- var node = this . hints . childNodes [ this . selectedHint ]
382+ var margin = this . completion . options . scrollMargin || 0 ;
383+ var node1 = this . hints . childNodes [ Math . max ( 0 , this . selectedHint - margin ) ] ;
384+ var node2 = this . hints . childNodes [ Math . min ( this . data . list . length - 1 , this . selectedHint + margin ) ] ;
383385 var firstNode = this . hints . firstChild ;
384- if ( node . offsetTop < this . hints . scrollTop )
385- this . hints . scrollTop = node . offsetTop - firstNode . offsetTop ;
386- else if ( node . offsetTop + node . offsetHeight > this . hints . scrollTop + this . hints . clientHeight )
387- this . hints . scrollTop = node . offsetTop + node . offsetHeight - this . hints . clientHeight + firstNode . offsetTop ;
386+ if ( node1 . offsetTop < this . hints . scrollTop )
387+ this . hints . scrollTop = node1 . offsetTop - firstNode . offsetTop ;
388+ else if ( node2 . offsetTop + node2 . offsetHeight > this . hints . scrollTop + this . hints . clientHeight )
389+ this . hints . scrollTop = node2 . offsetTop + node2 . offsetHeight - this . hints . clientHeight + firstNode . offsetTop ;
388390 } ,
389391
390392 screenAmount : function ( ) {
Original file line number Diff line number Diff line change @@ -2790,6 +2790,9 @@ <h2 id="addons">Addons</h2>
27902790 < dd > Like < code > customKeys</ code > above, but the bindings will
27912791 be added to the set of default bindings, instead of replacing
27922792 them.</ dd >
2793+ < dt > < code > < strong > scrollMargin</ strong > : integer</ code > </ dt >
2794+ < dd > Show this many lines before and after the selected item.
2795+ Default is 0.</ dd >
27932796 </ dl >
27942797 The following events will be fired on the completions object
27952798 during completion:
You can’t perform that action at this time.
0 commit comments