@@ -144,34 +144,18 @@ angular.module('ui.select', [])
144
144
compile : function ( tElement , tAttrs ) {
145
145
146
146
tElement . querySelectorAll ( '.ui-select-choices-row' )
147
- . attr ( " ng-repeat" , tAttrs . repeat )
148
- . attr ( " ng-mouseenter" , '$select.activeIdx= $index' )
149
- . attr ( " ng-click" , '$select.select(item)' ) ;
147
+ . attr ( ' ng-repeat' , tAttrs . repeat )
148
+ . attr ( ' ng-mouseenter' , '$select.activeIdx = $index' )
149
+ . attr ( ' ng-click' , '$select.select(item)' ) ;
150
150
151
151
return function ( scope , element , attrs , $select ) {
152
152
153
153
scope . trustAsHtml = function ( value ) {
154
154
return $sce . trustAsHtml ( value ) ;
155
155
} ;
156
156
157
- var container = element . hasClass ( 'ui-select-choices-content' ) ? element : element . querySelectorAll ( '.ui-select-choices-content' ) ;
158
-
159
- function ensureHighlightVisible ( ) {
160
- var rows = element . querySelectorAll ( '.ui-select-choices-row' ) ;
161
- if ( ! rows . length ) return ;
162
- var highlighted = rows [ scope . $select . activeIdx ] ,
163
- posY = highlighted . offsetTop + highlighted . clientHeight - container . scrollTop ,
164
- maxHeight = 200 ; // TODO Need to get this value from container.max-height
165
- if ( posY > maxHeight ) {
166
- container [ 0 ] . scrollTop += posY - maxHeight ;
167
- } else if ( posY < highlighted . clientHeight ) {
168
- container [ 0 ] . scrollTop -= highlighted . clientHeight - posY ;
169
- }
170
- }
171
-
172
157
scope . $watch ( '$select.search' , function ( ) {
173
158
scope . $select . activeIdx = 0 ;
174
- ensureHighlightVisible ( ) ;
175
159
} ) ;
176
160
177
161
// Bind keyboard events related to choices
@@ -184,15 +168,13 @@ angular.module('ui.select', [])
184
168
185
169
if ( evt . which === 40 ) { // down(40)
186
170
if ( scope . $select . activeIdx < rows . length ) {
187
- scope . $select . activeIdx = ( scope . $select . activeIdx + 1 ) % rows . length || rows . length - 1 ;
188
- ensureHighlightVisible ( ) ;
171
+ scope . $select . activeIdx = ( scope . $select . activeIdx + 1 ) % rows . length || rows . length - 1 ;
189
172
scope . $digest ( ) ;
190
173
}
191
174
192
175
} else if ( evt . which === 38 ) { // up(38)
193
176
if ( scope . $select . activeIdx > 0 ) {
194
177
scope . $select . activeIdx -- ;
195
- ensureHighlightVisible ( ) ;
196
178
scope . $digest ( ) ;
197
179
}
198
180
0 commit comments