Fix position issue when using up and down arrows to navigate the results.

abstract-chosen
Patrick Filler 2011-07-13 15:33:10 -04:00
parent ea87ad4df3
commit d5b62668ca
2 changed files with 3 additions and 7 deletions

View File

@ -280,7 +280,7 @@
maxHeight = parseInt(this.search_results.css("maxHeight"), 10);
visible_top = this.search_results.scrollTop();
visible_bottom = maxHeight + visible_top;
high_top = this.result_highlight.position().top;
high_top = this.result_highlight.position().top + this.search_results.scrollTop();
high_bottom = high_top + this.result_highlight.outerHeight();
if (high_bottom >= visible_bottom) {
return this.search_results.scrollTop((high_bottom - maxHeight) > 0 ? high_bottom - maxHeight : 0);

View File

@ -250,17 +250,13 @@ class Chosen
maxHeight = parseInt @search_results.css("maxHeight"), 10
visible_top = @search_results.scrollTop()
visible_bottom = maxHeight + visible_top
high_top = @result_highlight.position().top
high_top = @result_highlight.position().top + @search_results.scrollTop()
high_bottom = high_top + @result_highlight.outerHeight()
#console.log visible_top, visible_bottom, high_top, high_bottom
if high_bottom >= visible_bottom
#console.log "bottom is greater than bottom"
@search_results.scrollTop if (high_bottom - maxHeight) > 0 then (high_bottom - maxHeight) else 0
else if high_top < visible_top
#console.log "top is less than top"
@search_results.scrollTop high_top
result_clear_highlight: ->