Last active
August 8, 2024 13:24
-
-
Save osben/035dce09e288e8ae10ba to your computer and use it in GitHub Desktop.
jQuery Form Styler когда не влазит выпадающий список
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('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