Skip to content

Instantly share code, notes, and snippets.

@osben
Last active March 22, 2016 13:16
Show Gist options
  • Save osben/035dce09e288e8ae10ba to your computer and use it in GitHub Desktop.
Save osben/035dce09e288e8ae10ba to your computer and use it in GitHub Desktop.
jQuery Form Styler когда не влазит выпадающий список
$('select.styler').styler({
onSelectOpened:function() {
var el = $(this),
scrollTop = $(window).scrollTop(),
windowHeight = $(window).height(),
offset = el.offset(),
height = el.height() + el.find('.jq-selectbox__dropdown').height() + 20;
if((height + offset.top) > (scrollTop + windowHeight))
{
// не влазит
var newScrollTop = height + offset.top - windowHeight + 20;
$("html, body").animate({ scrollTop: newScrollTop }, '500', 'swing');
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment