From d5b62668ca9899e6910db8d59fbf0f24b80512ca Mon Sep 17 00:00:00 2001 From: Patrick Filler Date: Wed, 13 Jul 2011 15:33:10 -0400 Subject: [PATCH] Fix position issue when using up and down arrows to navigate the results. --- chosen/chosen.jquery.js | 2 +- coffee/chosen.jquery.coffee | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/chosen/chosen.jquery.js b/chosen/chosen.jquery.js index 4efe36a..c38ae81 100644 --- a/chosen/chosen.jquery.js +++ b/chosen/chosen.jquery.js @@ -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); diff --git a/coffee/chosen.jquery.coffee b/coffee/chosen.jquery.coffee index 1ea7baf..b440f6c 100644 --- a/coffee/chosen.jquery.coffee +++ b/coffee/chosen.jquery.coffee @@ -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: ->