Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery Chosen prevent automatic vertical scroll

I recently discovered a functionality of jQuery Chosen which automatically scrolls the .chosen-results Container downwards when you hover the bottom of the container.

Problem

I already found the function (result_do_highlight) which does that: here

This is the part where the automatic scroll happens in the function:

if high_bottom >= visible_bottom
    @search_results.scrollTop if (high_bottom - maxHeight) > 0 then (high_bottom - maxHeight) else 0
else if high_top < visible_top
    @search_results.scrollTop high_top

Is there a way to prevent scrolling?

Thank you in advance

EDIT

I forked the Chosen-git and added a workaround: github.com/puresamari/chosen

here is how to use it:

Changes from my side

I added the funtionallity to disable the automatic scroll towards the highlighted option: Use it like this:

$('your_select').chosen({
  scroll_to_highlighted: false
});

the parameter ´scroll_to_highlighted´ is optional and default true

like image 584
Simon Rothert Avatar asked Oct 19 '22 16:10

Simon Rothert


1 Answers

I forked the Chosen-git and added a workaround: github.com/puresamari/chosen

here is how to use it:

Changes from my side

I added the funtionallity to disable the automatic scroll towards the highlighted option: Use it like this:

$('your_select').chosen({
  scroll_to_highlighted: false
});

the parameter ´scroll_to_highlighted´ is optional and default true

like image 76
Simon Rothert Avatar answered Oct 21 '22 07:10

Simon Rothert